#include <stdio.h>
#define pi1 3.141
const float pi = 3.141;
int main()
{
printf("%f %f", 4 * 10 * pi, 4 * 10 * pi1);
}
Output (on my machine) is 125.639999 125.640000
pi1 is a preprocessor symbol and is replaced textually as a double.
pi is a float constant initialized from a double, and thus lose some precision bits (see IEEE754 specs).
For more details, pi as a float is in fact stored as 0x40490625 which is 3.1410000324249267578125. pi1 is stored as 0x400920C49BA5E354, which is 3.1410000000000000142108547152
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With