J
John
I'm new to C and I know this is probably one of those "most commonly
mis-interpreted as a problem", newcomer type of question, but for this code:
double x;
printf("Enter number:");
scanf("%f", &x);
printf("The number is %f", x);
If I enter 2 as the number, the following is returned:
-1.997517
This doesn't happen for 'float', only for 'double'.
Is there something I'm not getting here? Is there something I'm
supposed to be doing?
I'm teaching myself with GCC v3.3.6, and while I recall reading
somewhere that floating point numbers do slightly different things, I
didn't think they'd be THAT different!
mis-interpreted as a problem", newcomer type of question, but for this code:
double x;
printf("Enter number:");
scanf("%f", &x);
printf("The number is %f", x);
If I enter 2 as the number, the following is returned:
-1.997517
This doesn't happen for 'float', only for 'double'.
Is there something I'm not getting here? Is there something I'm
supposed to be doing?
I'm teaching myself with GCC v3.3.6, and while I recall reading
somewhere that floating point numbers do slightly different things, I
didn't think they'd be THAT different!