On Feb 22, 2014, at 1:28 PM, jonat...@mugginsoft.com wrote: > On 22 Feb 2014, at 15:32, Ken Thomases <k...@codeweavers.com> wrote: >>> >> >> NSDecimalNumber can represent values that are outside of the range of >> doubles. So, _some_ NSDecimalNumber instances _may_ return "d" for double, >> but others definitely won't. >> > I don’t think so. > It is possible that this behaviour could change and yes my type hinting > system would then break. > However, the current behaviour to me seems entirely self consistent. > > The NSDecimalNumber header says: > - (const char *)objCType NS_RETURNS_INNER_POINTER; > // return 'd' for double
Actually, this is much, much worse. If the representation provided by -getValue: is a double and a double can't represent all of the different values of an NSDecimalNumber, then two unequal number objects would have equal representations. That will play havoc with dictionary lookups. NSDecimalNumber* dn1 = [NSDecimalNumber decimalNumberWithMantissa:ULLONG_MAX exponent:0 isNegative:NO]; NSDecimalNumber* dn2 = [dn1 decimalNumberBySubtracting:[NSDecimalNumber one]]; double d1, d2; [dn1 getValue:&d1]; [dn2 getValue:&d2]; assert(![dn1 isEqual:dn2]); // passes assert(d1 != d2); // fails Regards, Ken _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com