I don't understand why I'm getting this output...
Here's the program
#include <stdio.h>
int main()
{
float x;
double y;
x = 145678.999817;
y = 145678.999817;
printf("Float is %f and double is %f\n", x, y);
x = 456.9998651;
y = 456.9998651;
printf("Float is %f and double is %f\n", x, y);
return 0;
}
OUTPUT:
Float is 145679.000000 and double is 145678.999817
Float is 456.999878 and double is 456.999865
---
I get the first line of the output, but I don't understand why the float = 456.999878 and double = 456.999865 on the second line.
Here's the program
#include <stdio.h>
int main()
{
float x;
double y;
x = 145678.999817;
y = 145678.999817;
printf("Float is %f and double is %f\n", x, y);
x = 456.9998651;
y = 456.9998651;
printf("Float is %f and double is %f\n", x, y);
return 0;
}
OUTPUT:
Float is 145679.000000 and double is 145678.999817
Float is 456.999878 and double is 456.999865
---
I get the first line of the output, but I don't understand why the float = 456.999878 and double = 456.999865 on the second line.