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

Re: number formatting


  • Subject: Re: number formatting
  • From: Greg Titus <email@hidden>
  • Date: Sat, 23 Feb 2002 21:26:05 -0800

On Saturday, February 23, 2002, at 01:23 PM, email@hidden wrote:

Lance, have you read what people have been telling you? Floating point
values don't have exact representations inside the machine.

Run this code and watch it in the debugger.

float value = 0.35;

printf("floating point value: %f\n", value);

The value is represented in the machine as 0.34999...

To force it to show up as 0.35 in a text field the text field would have
to force the precision to 2 places. Then you'd be still complaining about
the cases where you wanted more or less precision.

I believe what Lance is really arguing for is an infinite-precision numeric type in Cocoa. Which, I will admit, would be useful for many applications. :->


Not infinite precision, but if you are looking for a numeric value that is represented the same way you typed it in, you should probably look at NSDecimalNumber.

--Greg
_______________________________________________
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.

References: 
 >Re: number formatting (From: email@hidden)

  • Prev by Date: Re: sharing defaults between screensaver bundle and application
  • Next by Date: Re: What was EOF?
  • Previous by thread: Re: number formatting
  • Next by thread: Re: number formatting
  • Index(es):
    • Date
    • Thread