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