float vs. double?
- From: "Robert Wong" <robertwong@xxxxxxxxxxx>
- Date: Wed, 20 Dec 2006 11:03:21 -0500
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; // debugger - 1004714.7 float
danswer = value * lsb; // debugger - 1004714.7080078125 double
printf("\nFloat value Answer = %6.3f",answer);
printf("\nDouble value Answer = %6.3f",danswer);
/* output
Float value Answer = 1004714.688
Double value Answer = 1004714.708
*/
}
.
- Follow-Ups:
- Re: float vs. double?
- From: David Webber
- Re: float vs. double?
- From: David Wilkinson
- Re: float vs. double?
- Prev by Date: Re: Dialog Size Controlling
- Next by Date: Re: float vs. double?
- Previous by thread: Re: toolbar
- Next by thread: Re: float vs. double?
- Index(es):
Relevant Pages
|