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

inconsistent float behaviour


  • Subject: inconsistent float behaviour
  • From: Steven Hamilton <email@hidden>
  • Date: Fri, 10 Oct 2008 21:04:36 +1000

Hi folks,
I think I need some help understanding floats.

I have a class that calculates a balance and places it in a table column. At the end of this method I NSLog the output like so;

NSLog(@"current balance is: %@",balance);

and get

current balance is: 18976.69

in the console. So far so good.

The method plonks the balance into a table and returns it to whence it came. The table is sourced by the normal datasource delegate methods and the column has a number formatter on it set to Decimal #,##0,00## with half even rounding. I placed the last ##'s in there to check that the floats weren't producing decimals with more than 2 places but in my table column I get 18976.6995 which doesn't make sense. The float calculation is exactly 2 decimal places, I know that for a fact and NSLog proves it. Yet somehow, the table datasource appears to produce random decimal digits where i have the last ##.

Am I totally misunderstanding something about floats? Or is the extra ##'s in the formatter making things up?
_______________________________________________


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


  • Follow-Ups:
    • Re: inconsistent float behaviour
      • From: Uli Kusterer <email@hidden>
    • Re: inconsistent float behaviour
      • From: "Michael Ash" <email@hidden>
    • Re: inconsistent float behaviour
      • From: Nick Zitzmann <email@hidden>
    • Re: inconsistent float behaviour
      • From: Dave Carrigan <email@hidden>
  • Prev by Date: Re: Strategy for naming support folder
  • Next by Date: Re: NSCoding protocol
  • Previous by thread: Re: CalendarStore sync failure
  • Next by thread: Re: inconsistent float behaviour
  • Index(es):
    • Date
    • Thread