|
|
@ -11,58 +11,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
@implementation NSNumber
|
|
|
|
@implementation NSNumber
|
|
|
|
|
|
|
|
|
|
|
|
+ (NSNumber*)numberWithInt:(int)value {
|
|
|
|
|
|
|
|
// using alloc as the documentation doesn't say it may return nil
|
|
|
|
|
|
|
|
NSNumber* number = [self alloc];
|
|
|
|
|
|
|
|
return [number initWithInt:value];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (id)initWithInt:(int)v {
|
|
|
|
- (id)initWithInt:(int)v {
|
|
|
|
self->value = (double)v;
|
|
|
|
self->value = (double)v;
|
|
|
|
return self;
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+ (NSNumber*)numberWithFloat:(float)value {
|
|
|
|
- (id)initWithFloat:(float)v {
|
|
|
|
// using alloc as the documentation doesn't say it may return nil
|
|
|
|
return [self initWithInt:(int)v];
|
|
|
|
NSNumber* number = [NSNumber alloc];
|
|
|
|
|
|
|
|
return [number initWithInt:value];
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (id)initWithFloat:(float)v {
|
|
|
|
- (id)initWithBool:(BOOL)v {
|
|
|
|
self->value = (double)v;
|
|
|
|
return [self initWithInt:(int)v];
|
|
|
|
return self;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+ (NSNumber*)numberWithDouble:(double)value {
|
|
|
|
- (id)initWithDouble:(double)v {
|
|
|
|
|
|
|
|
return [self initWithInt:(int)v];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (id)initWithUnsignedInteger:(NSUInteger)v {
|
|
|
|
|
|
|
|
return [self initWithInt:(int)v];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ (NSNumber*)numberWithInt:(int)value {
|
|
|
|
// using alloc as the documentation doesn't say it may return nil
|
|
|
|
// using alloc as the documentation doesn't say it may return nil
|
|
|
|
NSNumber* number = [self alloc];
|
|
|
|
NSNumber* number = [self alloc];
|
|
|
|
return [number initWithInt:value];
|
|
|
|
return [number initWithInt:value];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (id)initWithDouble:(double)v {
|
|
|
|
+ (NSNumber*)numberWithChar:(char)value {
|
|
|
|
self->value = v;
|
|
|
|
return [NSNumber numberWithInt:(int)value];
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ (NSNumber*)numberWithShort:(short)value {
|
|
|
|
|
|
|
|
return [NSNumber numberWithInt:(int)value];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+ (NSNumber*)numberWithBool:(BOOL)value {
|
|
|
|
+ (NSNumber*)numberWithBool:(BOOL)value {
|
|
|
|
// using alloc as the documentation doesn't say it may return nil
|
|
|
|
return [NSNumber numberWithInt:(int)value];
|
|
|
|
NSNumber* number = [self alloc];
|
|
|
|
|
|
|
|
return [number initWithBool:value];
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (id)initWithBool:(BOOL)v {
|
|
|
|
+ (NSNumber*)numberWithInteger:(NSInteger)value {
|
|
|
|
self->value = (double)v;
|
|
|
|
return [NSNumber numberWithInt:(int)value];
|
|
|
|
return self;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (id)initWithUnsignedInteger:(NSUInteger)v {
|
|
|
|
+ (NSNumber*)numberWithFloat:(float)value {
|
|
|
|
self->value = v;
|
|
|
|
return [NSNumber numberWithInt:(int)value];
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ (NSNumber*)numberWithDouble:(double)value {
|
|
|
|
|
|
|
|
return [NSNumber numberWithInt:(int)value];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ (NSNumber*)numberWithLong:(long)value {
|
|
|
|
|
|
|
|
return [NSNumber numberWithInt:(int)value];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ (NSNumber*)numberWithLongLong:(long long)value {
|
|
|
|
|
|
|
|
return [NSNumber numberWithInt:(int)value];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ (NSNumber*)numberWithUnsignedInt:(unsigned int)value {
|
|
|
|
|
|
|
|
return [NSNumber numberWithInt:(int)value];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ (NSNumber*)numberWithUnsignedChar:(unsigned char)value {
|
|
|
|
|
|
|
|
return [NSNumber numberWithInt:(int)value];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ (NSNumber*)numberWithUnsignedShort:(unsigned short)value {
|
|
|
|
|
|
|
|
return [NSNumber numberWithInt:(int)value];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+ (NSNumber*)numberWithUnsignedInteger:(NSUInteger)value {
|
|
|
|
+ (NSNumber*)numberWithUnsignedInteger:(NSUInteger)value {
|
|
|
|
NSNumber* number = [self alloc];
|
|
|
|
return [NSNumber numberWithInt:(int)value];
|
|
|
|
return [number initWithUnsignedInteger:value];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ (NSNumber*)numberWithUnsignedLong:(unsigned long)value {
|
|
|
|
|
|
|
|
return [NSNumber numberWithInt:(int)value];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ (NSNumber*)numberWithUnsignedLongLong:(unsigned long long)value {
|
|
|
|
|
|
|
|
return [NSNumber numberWithInt:(int)value];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
@end
|
|
|
|