Name
NSDecimalNumber — Mac OS X 10.0
Synopsis
This subclass of NSNumber
provides an
object-oriented wrapper for performing base-10 arithmetic
operations. Instances of NSDecimalNumber
are
created with a string such as
“10.2e4” using
decimalNumberWithString
:, or by specifying the
mantissa, exponent, and whether or not it is negative in the method
decimalNumberWith-Mantissa:exponent:isNegative
:.
Arithmetic operations are performed
on two decimal number objects using methods such as
decimalNumberByAdding
:,
decimalNumberByMultiplying
:, and so forth. The
value of the decimal number can be accessed as a
double
by sending a doubleValue
message to the object.
|
@interface NSDecimalNumber : NSNumber
|
// Initializers
|
- (id)initWithDecimal:(NSDecimal)dcm; |
- (id)initWithMantissa:(unsigned long long)mantissa exponent:(short)exponent isNegative:(BOOL)flag; |
- (id)initWithString:(NSString *)numberValue; |
- (id)initWithString:(NSString *)numberValue locale:(NSDictionary *)locale; |
// Class Methods
|
+ (NSDecimalNumber *)decimalNumberWithDecimal:(NSDecimal)dcm; |
+ (NSDecimalNumber *)decimalNumberWithMantissa:(unsigned long long)mantissa exponent:(short)exponent isNegative:(BOOL)flag; |
+ (NSDecimalNumber *)decimalNumberWithString:(NSString *)numberValue; |
+ (NSDecimalNumber *)decimalNumberWithString:(NSString *)numberValue locale:(NSDictionary *)locale; |
+ (id <NSDecimalNumberBehaviors>) ... |
Get Cocoa in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.