floating vs. double

Tech-Archive recommends: Fix windows errors by optimizing your registry



Hi there,

I was wondering if someone can explain this? There seems to be a big
difference in the computation which the resultant is float vs. double. I'm
not sure if I understand it myself.

Is this a compiler problem? or just a precision loss?

Robert

---- simple C/C++ cold
#include <stdio.h>
#include <stdlib.h>

void main(void)
{
long int value = 1028827861;
float lsb = 0.0009765625;

float answer;
double danswer;

answer = value * lsb;
danswer = value * lsb;

printf("\nFloat value Answer = %6.3f",answer);
printf("\nDouble value Answer = %6.3f",danswer);

}


.



Relevant Pages

  • Re: floating vs. double
    ... There seems to be a big difference in the computation which the resultant is float vs. double. ... float lsb = 0.0009765625; ... double danswer; ...
    (microsoft.public.vstudio.development)
  • float vs. double?
    ... difference in the computation which the resultant is float vs. double. ... float lsb = 0.0009765625; ... double danswer; ...
    (microsoft.public.vc.mfc)
  • Re: float vs. double?
    ... Robert Wong wrote: ... difference in the computation which the resultant is float vs. double. ... It's just a precision issue. ...
    (microsoft.public.vc.mfc)