mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Fix initialisation of NSDeciamlNumber objects.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/branches/freeze-1_6_0@16045 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
396a0ce508
commit
d4a04c7c4d
2 changed files with 136 additions and 0 deletions
|
@ -2,6 +2,8 @@
|
|||
|
||||
* Source/Additions/GSObjCRuntime.m: GSObjCSetValue() correct to call
|
||||
([unableToSetNilForKey:]) when it should.
|
||||
* Source/NSDecimalNumber.m: Override initialisers from NSNumber to
|
||||
create NSDecimalNumber objects ... bug report by David Ayers.
|
||||
|
||||
2003-02-21 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
|
|
|
@ -271,6 +271,140 @@ static NSDecimalNumber *one;
|
|||
return [self initWithDecimal: decimal];
|
||||
}
|
||||
|
||||
- (id) initWithBool: (BOOL)value
|
||||
{
|
||||
return [self initWithMantissa: (value == YES) ? 1 : 0
|
||||
exponent: 0
|
||||
isNegative: NO];
|
||||
}
|
||||
|
||||
- (id) initWithChar: (signed char)value
|
||||
{
|
||||
if (value < 0)
|
||||
{
|
||||
return [self initWithMantissa: -value
|
||||
exponent: 0
|
||||
isNegative: YES];
|
||||
}
|
||||
else
|
||||
{
|
||||
return [self initWithMantissa: value
|
||||
exponent: 0
|
||||
isNegative: NO];
|
||||
}
|
||||
}
|
||||
|
||||
- (id) initWithDouble: (double)value
|
||||
{
|
||||
return [self initWithBytes: &value objCType: "d"];
|
||||
}
|
||||
|
||||
- (id) initWithFloat: (float)value
|
||||
{
|
||||
double d = (double)value;
|
||||
|
||||
return [self initWithBytes: &d objCType: "d"];
|
||||
}
|
||||
|
||||
- (id) initWithInt: (signed int)value
|
||||
{
|
||||
if (value < 0)
|
||||
{
|
||||
return [self initWithMantissa: -value
|
||||
exponent: 0
|
||||
isNegative: YES];
|
||||
}
|
||||
else
|
||||
{
|
||||
return [self initWithMantissa: value
|
||||
exponent: 0
|
||||
isNegative: NO];
|
||||
}
|
||||
}
|
||||
|
||||
- (id) initWithLong: (signed long)value
|
||||
{
|
||||
if (value < 0)
|
||||
{
|
||||
return [self initWithMantissa: -value
|
||||
exponent: 0
|
||||
isNegative: YES];
|
||||
}
|
||||
else
|
||||
{
|
||||
return [self initWithMantissa: value
|
||||
exponent: 0
|
||||
isNegative: NO];
|
||||
}
|
||||
}
|
||||
|
||||
- (id) initWithLongLong: (signed long long)value
|
||||
{
|
||||
if (value < 0)
|
||||
{
|
||||
return [self initWithMantissa: -value
|
||||
exponent: 0
|
||||
isNegative: YES];
|
||||
}
|
||||
else
|
||||
{
|
||||
return [self initWithMantissa: value
|
||||
exponent: 0
|
||||
isNegative: NO];
|
||||
}
|
||||
}
|
||||
|
||||
- (id) initWithShort: (signed short)value
|
||||
{
|
||||
if (value < 0)
|
||||
{
|
||||
return [self initWithMantissa: -value
|
||||
exponent: 0
|
||||
isNegative: YES];
|
||||
}
|
||||
else
|
||||
{
|
||||
return [self initWithMantissa: value
|
||||
exponent: 0
|
||||
isNegative: NO];
|
||||
}
|
||||
}
|
||||
|
||||
- (id) initWithUnsignedChar: (unsigned char)value
|
||||
{
|
||||
return [self initWithMantissa: value
|
||||
exponent: 0
|
||||
isNegative: NO];
|
||||
}
|
||||
|
||||
- (id) initWithUnsignedInt: (unsigned int)value
|
||||
{
|
||||
return [self initWithMantissa: value
|
||||
exponent: 0
|
||||
isNegative: NO];
|
||||
}
|
||||
|
||||
- (id) initWithUnsignedLong: (unsigned long)value
|
||||
{
|
||||
return [self initWithMantissa: value
|
||||
exponent: 0
|
||||
isNegative: NO];
|
||||
}
|
||||
|
||||
- (id) initWithUnsignedLongLong: (unsigned long long)value
|
||||
{
|
||||
return [self initWithMantissa: value
|
||||
exponent: 0
|
||||
isNegative: NO];
|
||||
}
|
||||
|
||||
- (id) initWithUnsignedShort: (unsigned short)value
|
||||
{
|
||||
return [self initWithMantissa: value
|
||||
exponent: 0
|
||||
isNegative: NO];
|
||||
}
|
||||
|
||||
- (NSString*) descriptionWithLocale: (NSDictionary*)locale
|
||||
{
|
||||
return NSDecimalString(&data, locale);
|
||||
|
|
Loading…
Reference in a new issue