Dart int isFinite
Syntax & Examples

int.isFinite property

The `isFinite` property in Dart returns true if the number is finite; otherwise, it returns false.


Syntax of int.isFinite

The syntax of int.isFinite property is:

 bool isFinite 

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

Return Type

int.isFinite returns value of type bool.



✐ Examples

1 Check if a finite number is finite

In this example,

  1. We assign the value 3.14 to the double variable num1.
  2. We check if num1 is finite using the isFinite property.
  3. We print the result to standard output.

Dart Program

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

Output

Is 3.14 finite? true

2 Check if positive infinity is finite

In this example,

  1. We assign double.infinity to the double variable num2.
  2. We check if num2 is finite using the isFinite property.
  3. We print the result to standard output.

Dart Program

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

Output

Is infinity finite? false

3 Check if NaN is finite

In this example,

  1. We assign double.nan to the double variable num3.
  2. We check if num3 is finite using the isFinite property.
  3. We print the result to standard output.

Dart Program

void main() {
  double num3 = double.nan;
  bool result3 = num3.isFinite;
  print('Is $num3 finite? $result3');
}

Output

Is NaN finite? false

Summary

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