Re: why are floats flakey?
Re: why are floats flakey?
- Subject: Re: why are floats flakey?
- From: Andrew Thompson <email@hidden>
- Date: Mon, 24 May 2004 23:41:00 -0400
On May 24, 2004, at 10:23 PM, justin webster wrote:
why are floats inaccurate?
when can I use them with confidence and what can I use in their place
when I need absolute accuracy?
i'm trying to create a float with a value of 29.97 and I get 29.9699999
like this:
float myFloat = [myTextField floatValue]
where the text field contains the string "29.97df"
Don't use floats if you need precise accuracy. Find a fixed precision
decimal representation.
This is not Cocoa specific, its common to most modern languages on most
modern CPUs
Research two's complement notation and IEEE 754 (try google) for
background info.
AndyT (lordpixel - the cat who walks through walls)
A little bigger on the inside
(see you later space cowboy ...)
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.