Dart num floorToDouble()
Syntax & Examples
num.floorToDouble() method
The `floorToDouble` method in Dart returns the greatest double integer value no greater than this.
Syntax of num.floorToDouble()
The syntax of num.floorToDouble() method is:
double floorToDouble()
This floorToDouble() method of num returns the greatest double integer value no greater than this.
Return Type
num.floorToDouble() returns value of type double
.
✐ Examples
1 Flooring a decimal number
In this example,
- We create a num variable
number1
with the value 5.6 and another variablenumber2
with the value -3.2. - We use the
floorToDouble()
method to get their floor values as double. - We then print the results to standard output.
Dart Program
void main() {
num number1 = 5.6;
num number2 = -3.2;
double result1 = number1.floorToDouble();
double result2 = number2.floorToDouble();
print('Floor of $number1: $result1');
print('Floor of $number2: $result2');
}
Output
Floor of 5.6: 5 Floor of -3.2: -4
2 Flooring an integer
In this example,
- We create a num variable
number
with the value 10. - We use the
floorToDouble()
method to get its floor value as double. - We then print the result to standard output.
Dart Program
void main() {
num number = 10.0;
double result = number.floorToDouble();
print('Floor of $number: $result');
}
Output
Floor of 10: 10
Summary
In this Dart tutorial, we learned about floorToDouble() method of num: the syntax and few working examples with output and detailed explanation for each example.