Re: 1.0 divided by 10 = 0.10000000000000001?
Re: 1.0 divided by 10 = 0.10000000000000001?
- Subject: Re: 1.0 divided by 10 = 0.10000000000000001?
- From: Derrick Bass <email@hidden>
- Date: Tue, 28 Mar 2006 17:29:39 -0600
On Mar 28, 2006, at 4:35 AM, Marcel Weiher wrote:
If so, the NSDecimalNumber is exactly what's needed.
Exactly not. Re-read Chris's post: NSDecimalNumber is *not* a BCD
( = exact base 10 ) representation, just an extended precision
floating point representation...
But, that completely contradicts the documentation, as well as the
very name of the class. Why in the world would you call it
NSDecimalNumber if it should be NSBinaryNumber? From the docs:
"NSDecimalNumber, an immutable subclass of NSNumber, provides an
object-oriented wrapper for doing ***base-10 arithmetic***. An
instance can represent ***any number that can be expressed as
mantissa x 10^exponent*** where mantissa is a decimal integer up to
38 digits long, and exponent is an integer from –128 through 127."
I've added highlighting to the appropriate parts. Yes, it's a
floating point representation, just like Chris said, but it's a
BASE-10 floating point representation, not base-2 like the native C-
types. Chris's post was unclear on this; he never directly said it
wasn't base-10, but he did imply it by contradicting what a previous
poster had said. For reference again, he said:
Actually no. NSDecimalNumber is a floating point representation,
with mantissa and exponent, just like doubles. It's just able to
represent a larger range/more precision than what had been
available natively from C-based languages and the compiler. "long
double" -- available in gcc 4.0 -- is about the same precision and
a much greater value range.
Chris has the high-trump apple.com email address, but even so I don't
think his quote is clear enough that we should simply disregard the
documentation, unless he's willing to explicitly disavow it.
Derrick
_______________________________________________
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