Re: Accurate decimal numbers?
Re: Accurate decimal numbers?
- Subject: Re: Accurate decimal numbers?
- From: Shawn Erickson <email@hidden>
- Date: Sat, 1 Jan 2005 12:44:54 -0800
On Jan 1, 2005, at 12:17 PM, mark wrote:
I can't duplicate this result using NSScanner's scanDouble. Maybe it
catches this case for me?
What you really want to do is avoid the use of floats / doubles all
together in this case. As Rick outlined instead use integers using a
defined unit.
In other words pick some unit and store your values in that form. Then
convert from the form to others as needed. For example say you decide
that your normalized form is millimeters (mm).
User inputs 10 cm store it as 100.
User inputs 1 m store it as 1000.
User inputs 1.555 m store it as 1555.
etc.
In other words know the users input units and parse input as needed
avoiding the use of floating point math in doing so.
-Shawn
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden