>>Can you explain my C
Actually yes, and beleive it or not, we were both right ! ;-)
I was right that there is no error when there is no rounding.
But I was wrong assuming there was no rounding; my problem was just
assuming that a number
as small as 74.82 could be exactly represented in a floating value.
The following test simply shows that even 24.82 is not represented
exactly by a float,
it is only correct as a double.
int main()
{
float x = 24.82;
double y = 24.82;
printf ("x = %20.20e\ny = %20.20e\n", x, y);
}
But I still can't explain why, since a mantissa for a float is supposed
to be 23 bits long,
far sufficient to represent a 4 digits value.
After all, the whole big idea of floating values is to use the mantissa
to represent as much
significant digits as possible, and "put" this value in the correct
range using the exponent.
So why it doesn't work for 24.82 is still a mystery.
--
_______________________________________
REUSE CODE! Use custom tags;
See http://www.contentbox.com/claude/customtags/tagstore.cfm
(Please send any spam to this address: [EMAIL PROTECTED])
Thanks.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Find out how CFTicket can increase your company's customer support
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:226336
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54