Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - The conversion problem between real type and integer type in C language (very urgent)
The conversion problem between real type and integer type in C language (very urgent)
B) x = y * 100 +0.5,y = x / 100.0

For example: y = 3. 14 15926.

x = y * 100 + 0.5

The result of Y * 100 is 3 14. 15.

+0.5, the result is 3 14.65. If the value is assigned to the int type, then X = 3 14.

Then: y = 3.14;

If y = 6.2 1854, then

x = y * 100 + 0.5

The result of Y * 100 is 62 1.854.

After +0.5, the result is 622.354. If it is assigned to int type x, then X = 622.

So: y = 6.22