• 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: Problem with Float type variable
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with Float type variable


  • Subject: Re: Problem with Float type variable
  • From: Alastair Houghton <email@hidden>
  • Date: Sat, 15 Aug 2009 09:50:47 +0100

On 15 Aug 2009, at 08:01, Adil Saleem wrote:

But why would it round 863.6 ? I mean there is only 1 digit after the decimal. It should not have the range problem with a value this small.

Decimal numbers are not necessarily exactly representable in binary. The C library makes it look like some of them are in many cases by careful rounding in its output routines, but of course it cannot always hide the fact that some numbers are necessarily inexact.


A very good document was published in ACM Computing Surveys back in 1991, entitled "What Every Computer Scientist Should Know About Floating-Point Arithmetic". Sun Microsystems reprinted it in 1994, and you can get a PDF of that version here:

  <http://dlc.sun.com/pdf/800-7895/800-7895.pdf>

It's very aptly titled and well worth reading.

Kind regards,

Alastair.

--
http://alastairs-place.net



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Re: Problem with Float type variable (From: Adil Saleem <email@hidden>)

  • Prev by Date: Re: CTLineCreateWithAttributedString ignoring font size
  • Next by Date: Re: Multi-User DB That Talks to Core Data?
  • Previous by thread: Re: Problem with Float type variable
  • Next by thread: Re: Problem with Float type variable
  • Index(es):
    • Date
    • Thread