mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-21 04:32:03 +00:00
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:
parent
682353c892
commit
183c6055cc
5 changed files with 137 additions and 80 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue