The `isNaN` property in Dart returns true if the number is the double Not-a-Number value; otherwise, it returns false.
The syntax of int.isNaN property is:
bool isNaN
This isNaN property of int true if the number is the double Not-a-Number value; otherwise, false.
int.isNaN returns value of type bool
.
In this example,
3.14
to the double variable num1
.num1
is NaN using the isNaN
property.void main() {
double num1 = 3.14;
bool result1 = num1.isNaN;
print('Is $num1 NaN? $result1');
}
Is 3.14 NaN? false
In this example,
double.infinity
to the double variable num2
.num2
is NaN using the isNaN
property.void main() {
double num2 = double.infinity;
bool result2 = num2.isNaN;
print('Is $num2 NaN? $result2');
}
Is infinity NaN? false
In this example,
double.nan
to the double variable num3
.num3
is NaN using the isNaN
property.void main() {
double num3 = double.nan;
bool result3 = num3.isNaN;
print('Is $num3 NaN? $result3');
}
Is NaN NaN? true
In this Dart tutorial, we learned about isNaN property of int: the syntax and few working examples with output and detailed explanation for each example.