i'm trying to play around and learn c while making a ohms calculator. now i have a strange thing happening when the resistance(output) is 0.001 then it prints out 1000uOhm instead of 1 mOhm
case 1:
printf("what is your Voltage?\n");
scanf("%Lf", &volt);
printf("what is your Amperage?\n");
scanf("%Lf", &ere);
output = volt / ampere;
if (output >= 0.0000000001 && output < 0.000001) {
printf("%0.0Lf %s\n", output * 1e6, "nOhm"); // Convert to nano
printf("%0.9Lf %s\n", output, "Ohm"); // Display as is
}
if (output >= 0.000001 && output < 0.001) {
printf("%0.0Lf %s\n", output * 1e6, "uOhm"); // Convert to micro
printf("%0.9Lf %s\n", output, "Ohm"); // Display as is
}
if (output >= 0.001 && output < 1 ) {
printf("%0.0Lf %s\n", output * 1e3, "mOhm"); // Convert to mili
printf("%0.9Lf %s\n", output, "Ohm"); // Display as is
}
if (output > 1) {
printf("%0.0Lf Ohm\n", output);
}
break;
full code https://github.com/toku1991/ElectronicsCalculator
if i change if (output >= 0.001 && output < 1 ) to if (output >= 0.0009 && output < 1 ) it works but i would like to know whats going wrong?