Dart double ceilToDouble()
Syntax & Examples


double.ceilToDouble() method

The `ceilToDouble` method returns the least integer double value no smaller than the given double.


Syntax of double.ceilToDouble()

The syntax of double.ceilToDouble() method is:

 double ceilToDouble() 

This ceilToDouble() method of double returns the least integer double value no smaller than this.

Return Type

double.ceilToDouble() returns value of type double.



✐ Examples

1 Find the ceiling value of a positive decimal

In this example,

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

Dart Program

void main() {
  double num = 3.14;
  double ceilValue = num.ceilToDouble();
  print('Ceiling value of 3.14: $ceilValue');
}

Output

Ceiling value of 3.14: 4

2 Find the ceiling value of a negative decimal

In this example,

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

Dart Program

void main() {
  double num = -5.6;
  double ceilValue = num.ceilToDouble();
  print('Ceiling value of -5.6: $ceilValue');
}

Output

Ceiling value of -5.6: -5

3 Find the ceiling value of a whole number

In this example,

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

Dart Program

void main() {
  double num = 10.0;
  double ceilValue = num.ceilToDouble();
  print('Ceiling value of 10.0: $ceilValue');
}

Output

Ceiling value of 10.0: 10

Summary

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