Re: Problem with Float type variable
Re: Problem with Float type variable
- Subject: Re: Problem with Float type variable
- From: Alastair Houghton <email@hidden>
- Date: Sat, 15 Aug 2009 09:50:47 +0100
On 15 Aug 2009, at 08:01, Adil Saleem wrote:
But why would it round 863.6 ? I mean there is only 1 digit after
the decimal. It should not have the range problem with a value this
small.
Decimal numbers are not necessarily exactly representable in binary.
The C library makes it look like some of them are in many cases by
careful rounding in its output routines, but of course it cannot
always hide the fact that some numbers are necessarily inexact.
A very good document was published in ACM Computing Surveys back in
1991, entitled "What Every Computer Scientist Should Know About
Floating-Point Arithmetic". Sun Microsystems reprinted it in 1994,
and you can get a PDF of that version here:
<http://dlc.sun.com/pdf/800-7895/800-7895.pdf>
It's very aptly titled and well worth reading.
Kind regards,
Alastair.
--
http://alastairs-place.net
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden