• 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: double: Decimal places
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: double: Decimal places


  • Subject: Re: double: Decimal places
  • From: mathew <email@hidden>
  • Date: Wed, 16 Jul 2003 22:44:27 -0400

On Tuesday, July 15, 2003, at 07:37 AM, Cyprien wrote:
I'm trying to have at least 9 decimal places with the numbers I manipulate. I use double, which garanties normally at least 15 decimal places.

Assuming you want your 9 decimal places to be accurate, floating point is not the answer, unless you have some fairly low upper bounds on the numbers you might need to handle. Double doesn't guarantee 15 decimal *places*; it guarantees 15 decimal *digits* of accuracy. So if you want to represent 123456789.123456789 (say) you're out of luck.

(See <URL:http://babbage.cs.qc.edu/courses/cs341/IEEE-754.html> if you want to test this assertion.)

So if you really need 9 decimal places of accuracy, rather than 9 decimal digits of accuracy, and if your numbers may get significantly larger than a million or so, then you may need to implement fixed point (arbitrary precision) math, or find a fixed point math library somewhere.

Beware also that not all decimal numbers with 9 decimal places will have accurate finite length binary double float representations.


mathew
_______________________________________________
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.

References: 
 >double: Decimal places (From: Cyprien <email@hidden>)

  • Prev by Date: Searching for Specific Files/Problem with hiding on login
  • Next by Date: NSToolbar Acting as Tabs
  • Previous by thread: Re: double: Decimal places
  • Next by thread: Re: (10.0.x) option-clicking in statusbar hides active app (update)...
  • Index(es):
    • Date
    • Thread