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