The `floorToDouble` method in Dart returns this converted to a double.
The syntax of int.floorToDouble() method is:
double floorToDouble()
This floorToDouble() method of int returns this.toDouble().
int.floorToDouble() returns value of type double
.
In this example,
num
with the value 4.floorToDouble()
method to convert it to a double.void main() {
int num = 4;
double floorDouble = num.floorToDouble();
print('Floor to double of $num: $floorDouble');
}
Floor to double of 4: 4
In this example,
negativeNum
with the value -3.floorToDouble()
method to convert it to a double.void main() {
int negativeNum = -3;
double floorDoubleNegative = negativeNum.floorToDouble();
print('Floor to double of $negativeNum: $floorDoubleNegative');
}
Floor to double of -3: -3
In this example,
integerNum
with the value 7.floorToDouble()
method to convert it to a double.void main() {
int integerNum = 7;
double floorDoubleInteger = integerNum.floorToDouble();
print('Floor to double of $integerNum: $floorDoubleInteger');
}
Floor to double of 7: 7
In this Dart tutorial, we learned about floorToDouble() method of int: the syntax and few working examples with output and detailed explanation for each example.