当我输入0.2作为音量我应该得到2260.00但我得到2260.001并且我无法理解为什么。即使在调整了我想要的小数数量之后,最后也总是0.1 ......
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int option;
float volume;
float density = 11300;
float mass;
while (option != 3)
{
printf("1: Calculate Mass\n");
printf("2: Calculate Volume\n");
printf("3: Exit\n");
printf("Input here: ");
scanf("%d", &option);
if (option == 1)
{
printf("Input Volume: ");
scanf("%f", &volume);
mass = volume*density;
printf("%.2f", mass);
}
}
return 0;
}