Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Accurate decimal numbers?




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: http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Re: Accurate decimal numbers? (From: mark <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.