I use [NSNumber numberWithDouble:] method to form my NSNumber. H开发者_JAVA技巧owever, since some of the values might be large, I want to know if there is a way to tell NSNumber to represent itself with the scientific notation. Thanks in advance!
Take a look at NSDecimalNumber. They allow for higher precision than NSNumber
, and support scientific notation and other features.
Try turning the number into as string and use the scientific print formatter %e
, or %E
I say this because there is no point in trying to get the NSNumber to format itself because it is only an object wrapper around a value. When you want to present the number, then treat it as a string and use the NSString methods to show the value in the way that you want.
精彩评论