Dart double floorToDouble()
Syntax & Examples

double.floorToDouble() method

The `floorToDouble` method returns the greatest integer double value no greater than the given double.


Syntax of double.floorToDouble()

The syntax of double.floorToDouble() method is:

 double floorToDouble() 

This floorToDouble() method of double returns the greatest integer double value no greater than this.

Return Type

double.floorToDouble() returns value of type double.



✐ Examples

1 Find the floor value of a positive decimal

In this example,

  1. We define a double num with a value of 3.14.
  2. We call the floorToDouble() method on num to find its floor value.
  3. We print the result to standard output.

Dart Program

void main() {
  double num = 3.14;
  double floorValue = num.floorToDouble();
  print('Floor value of 3.14: $floorValue');
}

Output

Floor value of 3.14: 3

2 Find the floor value of a negative decimal

In this example,

  1. We define a double num with a value of -5.6.
  2. We call the floorToDouble() method on num to find its floor value.
  3. We print the result to standard output.

Dart Program

void main() {
  double num = -5.6;
  double floorValue = num.floorToDouble();
  print('Floor value of -5.6: $floorValue');
}

Output

Floor value of -5.6: -6

3 Find the floor value of a whole number

In this example,

  1. We define a double num with a value of 10.0.
  2. We call the floorToDouble() method on num to find its floor value.
  3. We print the result to standard output.

Dart Program

void main() {
  double num = 10.0;
  double floorValue = num.floorToDouble();
  print('Floor value of 10.0: $floorValue');
}

Output

Floor value of 10.0: 10

Summary

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