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

Float behaviour


  • Subject: Float behaviour
  • From: Richard Gray <email@hidden>
  • Date: Mon, 22 Aug 2005 18:19:39 +0100

Hi all...

I'm new to Cocoa and Objective C and have just been running through
the Currency Converter example on developer.apple.com.  That seemed
fairly straightforward and the application runs, but I notice some
strange behaviour in it that I haven't seen mentioned anywhere else.

If I were to convert $1 at an exchange rate of 1.2, I'd expect to get
1.2 units of the new currency yes?  According to my currency converter
however, 1 x 1.2 = 1.200000047683716

Can someone explain this behaviour to me and how to avoid it?  I wrote
another small app that takes an number entered into 1 text field and
writes it to another when I press a button.  It shows the same
behaviour.

I'm sure there's a simple explanation for this, but I'm just not
seeing at the moment.

thanks!

Richard
 _______________________________________________
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: Float behaviour
      • From: Todd Yandell <email@hidden>
    • Re: Float behaviour
      • From: Scott Ribe <email@hidden>
    • Re: Float behaviour
      • From: ObjM2 <email@hidden>
    • Re: Float behaviour
      • From: Jim Hamilton <email@hidden>
  • Prev by Date: Re: Clearing NSTableView on unbind
  • Next by Date: Re: Float behaviour
  • Previous by thread: Re: Why use copy in value setters?
  • Next by thread: Re: Float behaviour
  • Index(es):
    • Date
    • Thread