Dart double isFinite
Syntax & Examples

double.isFinite property

The `isFinite` property checks if the number is finite.


Syntax of double.isFinite

The syntax of double.isFinite property is:

 bool isFinite 

This isFinite property of double true if the number is finite; otherwise, false.

Return Type

double.isFinite returns value of type bool.



✐ Examples

1 Check if a finite number is finite

In this example,

  1. We define a double num with a finite value of 3.14.
  2. We access the isFinite property to check if num is finite.
  3. We print the result to standard output.

Dart Program

void main() {
  double num = 3.14;
  bool isNumFinite = num.isFinite;
  print('Is 3.14 finite? $isNumFinite');
}

Output

Is 3.14 finite? true

2 Check if infinity is finite

In this example,

  1. We define a double num with a value of positive infinity.
  2. We access the isFinite property to check if num is finite.
  3. We print the result to standard output.

Dart Program

void main() {
  double num = double.infinity;
  bool isNumFinite = num.isFinite;
  print('Is infinity finite? $isNumFinite');
}

Output

Is infinity finite? false

3 Check if NaN is finite

In this example,

  1. We define a double num with a value of NaN.
  2. We access the isFinite property to check if num is finite.
  3. We print the result to standard output.

Dart Program

void main() {
  double num = double.nan;
  bool isNumFinite = num.isFinite;
  print('Is NaN finite? $isNumFinite');
}

Output

Is NaN finite? false

Summary

In this Dart tutorial, we learned about isFinite property of double: the syntax and few working examples with output and detailed explanation for each example.