Add decimalValue imp.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@14280 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Adam Fedor 2002-08-15 14:46:51 +00:00
parent 682353c892
commit 183c6055cc
5 changed files with 137 additions and 80 deletions

View file

@ -528,3 +528,17 @@ static NSDecimalNumber *one;
}
@end
@implementation NSNumber (NSDecimalNumber)
/** Returns an NSDecimal representation of the number. Float and double
values may not be converted exactly */
- (NSDecimal) decimalValue
{
double num;
NSDecimalNumber *dnum;
num = [self doubleValue];
dnum = [[NSDecimalNumber alloc] initWithBytes: &num objCType: "d"];
return [dnum decimalValue];
}
@end