• 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 number formatting problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Float number formatting problem


  • Subject: Float number formatting problem
  • From: Ian Gillespie <email@hidden>
  • Date: Thu, 8 May 2003 23:56:23 -0700

I am having trouble with NSNumberFormatter formatting large floats correctly.

I have an outline view which displays large monetary amounts as floats. The cells for that column use a number formatter . The user can edit the amounts by double clicking them. This works fine if the user enters in values less than about 99,999.98. Once the user enters more than that, the pennies start to be rounded to the nearest ten cents. I put an NSLog() in my model class to see what the float value looks like before it is returned to the outline view and it looks like this: -199999.937500 The is the amount returned for when the user enters 199,999.94. This amount when it appears in the outline view is: 199,999.90

I have also tried using an integer, multiplying the amount by 100 and then dividing by 100 and then returning a value that looks like 199,999.94 in the console, but the formatter still rounds it.

Am I missing something about floats, or number formatting?

Thank you.
_______________________________________________
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.

  • Prev by Date: Re: messages to nil
  • Next by Date: getting file type info from NSOpenPanel's selected file
  • Previous by thread: Re: messages to nil
  • Next by thread: getting file type info from NSOpenPanel's selected file
  • Index(es):
    • Date
    • Thread