The `isOdd` property checks whether a given big integer is odd.
The syntax of BigInt.isOdd property is:
bool isOdd
This isOdd property of BigInt whether this big integer is odd.
BigInt.isOdd returns value of type bool
.
In this example,
num1
and num2
, initialized with 10 and 15 respectively.isOdd
property to check if these numbers are odd.void main() {
BigInt num1 = BigInt.from(10);
BigInt num2 = BigInt.from(15);
bool isOdd1 = num1.isOdd;
bool isOdd2 = num2.isOdd;
print('10 is odd: $isOdd1');
print('15 is odd: $isOdd2');
}
10 is odd: false 15 is odd: true
In this example,
num
, initialized with -7.isOdd
property to check if this number is odd.void main() {
BigInt num = BigInt.from(-7);
bool isOdd = num.isOdd;
print('-7 is odd: $isOdd');
}
-7 is odd: true
In this example,
num
, by parsing the string '123456789012345678901234567890'.isOdd
property to check if this large number is odd.void main() {
BigInt num = BigInt.parse('123456789012345678901234567890');
bool isOdd = num.isOdd;
print('Large number is odd: $isOdd');
}
Large number is odd: true
In this Dart tutorial, we learned about isOdd property of BigInt: the syntax and few working examples with output and detailed explanation for each example.