Then I wrote two pieces of code, but basically the same, just for variable data definition is a float type definition, one is a double type definition,
# include & lt; Stdio. H>
# include & lt; Stdlib. H>
/* run this program using the console pauser or add your own getch, system (" pause ") or the input loop */
Int main (int arg c, char * argv []) {
Float Celsius, fahr;
Printf (" Celsius=");
The scanf (" % f ", & amp; Celsius);
Fahr=(9/5.0) * Celsius + 32;
Printf (" fahr=% f ", fahr);
return 0;
}
//the result: 98.959999
# include & lt; Stdio. H>
# include & lt; Stdlib. H>
/* run this program using the console pauser or add your own getch, system (" pause ") or the input loop */
Int main (int arg c, char * argv []) {
Double Celsius, fahr;
Printf (" Celsius=");
Lf the scanf (" % ", & amp; Celsius);
Fahr=(9/5.0) * Celsius + 32;
Printf (" fahr=% lf ", fahr);
return 0;
}
//the result: 98.960000
Want to ask is what operation process out of the question? What is the principle?
CodePudding user response:
No any problem, you have found a float and double precision of different good chestnut, praise a ha,CodePudding user response:
Mean any less 0.000001? My compiler is more than 0.000001, the data is stored in binary, double eight bytes, but only 4 bytes, float will cause error (0.000001)