Info In the example, the two numbers 123.456 and 123.987 are rounded down to the nearest integer.
And This means that regardless of how close they are close to 124, they are rounded to 123.
Note Floor can be useful when rounding numbers that are part of a larger representation of another number.
static void Main()
// Two values.
double value1 = 123.456;
double value2 = 123.987;
// Take floors of these values.
double floor1 = Math.Floor(value1);
double floor2 = Math.Floor(value2);
// Write first value and floor.
// Write second value and floor.
Discussion. When given a positive number, Floor() erases the digits after the decimal place. With a negative number, Floor erases the digits and increases the number's negativity by 1.
So Using Math.Floor on a negative number will still decrease the total number. This means it will always become smaller.
Decimal. Math.Floor can be used with the decimal type—the decimal.Floor static method is immediately called into. It is sometimes clearer to directly use decimal.Floor.