I am converting an algorithm written in Java to Objective-C. In java, the BigDecimal class handles base-10 numbers and can take a primitive double as the arg constructor. However, in the Cocoa NSDecimalNumber class, there is no direct way to instantiate using a primitive double.
I am currently using this (smelly) hack:
[NSDecimalNumber decimalNumberWithString:[NSString stringWithFormat:@"%1.38f", number]];
Is there a better way?
source
share