Number sign Property


Advertisements

Returns minus one, zero or plus one depending on the sign and numerical value of the number.

This property returns minus one if the number is lesser than zero, plus one if the number is greater than zero and zero if the number is equal to zero.

Syntax

num.sign

Example

void main() { 
   int posNum = 10; 
   int negNum = -12;
   int valZero = 0;  
   
   print(posNum.sign); 
   print(negNum.sign); 
   print(valZero.sign); 
}  

It will produce the following output

1 
-1 
0
dart_programming_numbers.htm
Advertisements