The `floor` method in Dart returns this integer itself.
The syntax of int.floor() method is:
int floor()
This floor() method of int returns this.
int.floor() returns value of type int
.
In this example,
5
to the integer variable num1
.num1
using the floor()
method, which is the number itself.void main() {
int num1 = 5;
int floorNum1 = num1.floor();
print('Floor of $num1: $floorNum1');
}
Floor of 5: 5
In this example,
-3
to the integer variable num2
.num2
using the floor()
method, which is the number itself.void main() {
int num2 = -3;
int floorNum2 = num2.floor();
print('Floor of $num2: $floorNum2');
}
Floor of -3: -3
In this example,
10
to the integer variable num3
.num3
using the floor()
method, which is the number itself.void main() {
int num3 = 10;
int floorNum3 = num3.floor();
print('Floor of $num3: $floorNum3');
}
Floor of 10: 10
In this Dart tutorial, we learned about floor() method of int: the syntax and few working examples with output and detailed explanation for each example.