• 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: inconsistent float behaviour
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: inconsistent float behaviour


  • Subject: Re: inconsistent float behaviour
  • From: ghe <email@hidden>
  • Date: Fri, 10 Oct 2008 11:29:50 -0600

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Nick Zitzmann wrote:
>
> On Oct 10, 2008, at 5:04 AM, Steven Hamilton wrote:
>
>> Am I totally misunderstanding something about floats? Or is the extra
>> ##'s in the formatter making things up?
>
>
> Floating point values of either float or double are not guaranteed to be
> super precise, and should never be used to represent currency values.
> Try using a long long instead, and have the first two digits represent a
> fractional unit of currency.

Keep in mind that despite the decimal point (US $$), money is an
integer. If you're using a 64 bit int, there's room to shift it over 8
bits or so to give a little roundoff space for division and percents and
the like.

Unless you're working with your losses in the stock market (Oct 2008)...

- --
Glenn English
email@hidden

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkjvkQ4ACgkQ04yQfZbbTLYj8QCdEHM8nQplWqwsLHn9j8yCcqmT
qvIAn12OoUgbvZURYvP+VOnU3/h2CuV2
=8jm1
-----END PGP SIGNATURE-----
_______________________________________________

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: 
 >inconsistent float behaviour (From: Steven Hamilton <email@hidden>)
 >Re: inconsistent float behaviour (From: Nick Zitzmann <email@hidden>)

  • Prev by Date: Re: Finder Crashes on File Open
  • Next by Date: Re: Strategy for naming support folder
  • Previous by thread: Re: inconsistent float behaviour
  • Next by thread: Re: inconsistent float behaviour
  • Index(es):
    • Date
    • Thread