Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - How to force rounding in vs
How to force rounding in vs

vs forces rounding as follows.

(1) Use int coercion. The result of using int coercion is to remove the decimal part.

int a;a=int(2.2); //a=2 a=int(-2.2); //a=-2

(2) Use the floor function to round down using the floor function The result is rounded down, that is, the maximum integer smaller than this number is obtained, and the header file math.h needs to be included

(3) Use the ceil function to round up. The result of using the ceil function is rounded up. That is, to get the smallest integer larger than this number, you need to include the header file math.h