[Reserved] Math.Floor method to use C # rounding down

In the numerical calculation of C #, the results sometimes need to truncation of the fractional bits are reserved bits rounded down to an integer, this time can be achieved using the built-in methods Math.Floor rounding-down operation, the method Math.Floor removing the decimal portion reserved integer. There are two methods Math.Floor overloaded functions, one of Math.Floor (double value), the other is Math.Floor (decimal value), value of the representative value of the variables required rounding down.

(1) the value of double type is rounded down operation

double num = 3.444D;

num = Math.Floor (num); // result is calculated num = 3;

(2) the type of decimal numeric decimal rounding operation is rounded down

decimal num = 3.444M;

num = Math.Floor (num); // result is calculated num = 3;

Note: The text reproduced from personal bloggers station IT technology small fun house , the original link C # method to use Math.Floor rounded down _IT technology small fun house .

Guess you like

Origin www.cnblogs.com/xu-yi/p/10993569.html