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,
- We define a double
numwith a value of3.14. - We call the
ceilToDouble()method onnumto find its ceiling value. - 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,
- We define a double
numwith a value of-5.6. - We call the
ceilToDouble()method onnumto find its ceiling value. - 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,
- We define a double
numwith a value of10.0. - We call the
ceilToDouble()method onnumto find its ceiling value. - 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.