• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Accurate decimal numbers?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: Accurate decimal numbers?
      • From: mark <email@hidden>
References: 
 >Re: Accurate decimal numbers? (From: mark <email@hidden>)

  • Prev by Date: Re: Accurate decimal numbers?
  • Next by Date: Re: EPS to NSBezierPath
  • Previous by thread: Re: Accurate decimal numbers?
  • Next by thread: Re: Accurate decimal numbers?
  • Index(es):
    • Date
    • Thread