The `isNaN` property checks if the number is the double Not-a-Number (NaN) value.
The syntax of double.isNaN property is:
bool isNaN
This isNaN property of double true if the number is the double Not-a-Number value; otherwise, false.
double.isNaN returns value of type bool
.
In this example,
num
with a finite value of 3.14
.isNaN
property to check if num
is NaN.void main() {
double num = 3.14;
bool isNumNaN = num.isNaN;
print('Is 3.14 NaN? $isNumNaN');
}
Is 3.14 NaN? false
In this example,
num
with a value of positive infinity.isNaN
property to check if num
is NaN.void main() {
double num = double.infinity;
bool isNumNaN = num.isNaN;
print('Is infinity NaN? $isNumNaN');
}
Is infinity NaN? false
In this example,
num
with a value of NaN.isNaN
property to check if num
is NaN.void main() {
double num = double.nan;
bool isNumNaN = num.isNaN;
print('Is NaN NaN? $isNumNaN');
}
Is NaN NaN? true
In this Dart tutorial, we learned about isNaN property of double: the syntax and few working examples with output and detailed explanation for each example.