The `sign` property in Dart returns the sign of this integer.
The syntax of int.sign property is:
int sign
This sign property of int returns the sign of this integer.
int.sign returns value of type int
.
In this example,
number1
with the value 10.sign
property to get its sign.void main() {
int number1 = 10;
int sign1 = number1.sign;
print('Sign of $number1: $sign1');
}
Sign of 10: 1
In this example,
number2
with the value -7.sign
property to get its sign.void main() {
int number2 = -7;
int sign2 = number2.sign;
print('Sign of $number2: $sign2');
}
Sign of -7: -1
In this example,
zero
with the value 0.sign
property to get its sign.void main() {
int zero = 0;
int signZero = zero.sign;
print('Sign of $zero: $signZero');
}
Sign of 0: 0
In this Dart tutorial, we learned about sign property of int: the syntax and few working examples with output and detailed explanation for each example.