44 var result =
new Number();
45 result.isa = [
self class];
49 + (id)numberWithBool:(BOOL)aBoolean
51 return aBoolean ? 1 : 0;
54 + (id)numberWithChar:(
char)aChar
57 return aChar.charCodeAt(0);
62 + (id)numberWithDouble:(
double)aDouble
67 + (id)numberWithFloat:(
float)aFloat
72 + (id)numberWithInt:(
int)anInt
77 + (id)numberWithLong:(
long)aLong
82 + (id)numberWithLongLong:(
long long)aLongLong
87 + (id)numberWithShort:(
short)aShort
92 + (id)numberWithUnsignedChar:(
unsigned char)aChar
95 return aChar.charCodeAt(0);
100 + (id)numberWithUnsignedInt:(
unsigned)anUnsignedInt
102 return anUnsignedInt;
105 + (id)numberWithUnsignedLong:(
unsigned long)anUnsignedLong
107 return anUnsignedLong;
115 + (id)numberWithUnsignedShort:(
unsigned short)anUnsignedShort
117 return anUnsignedShort;
120 - (id)initWithBool:(BOOL)aBoolean
125 - (id)initWithChar:(
char)aChar
127 if (aChar.charCodeAt)
128 return aChar.charCodeAt(0);
133 - (id)initWithDouble:(
double)aDouble
138 - (id)initWithFloat:(
float)aFloat
143 - (id)initWithInt:(
int)anInt
148 - (id)initWithLong:(
long)aLong
153 - (id)initWithLongLong:(
long long)aLongLong
158 - (id)initWithShort:(
short)aShort
163 - (id)initWithUnsignedChar:(
unsigned char)aChar
165 if (aChar.charCodeAt)
166 return aChar.charCodeAt(0);
171 - (id)initWithUnsignedInt:(
unsigned)anUnsignedInt
173 return anUnsignedInt;
176 - (id)initWithUnsignedLong:(
unsigned long)anUnsignedLong
178 return anUnsignedLong;
186 - (id)initWithUnsignedShort:(
unsigned short)anUnsignedShort
188 return anUnsignedShort;
197 UID = objj_generateObjectUID();
207 return self ?
true :
false;
212 return String.fromCharCode(
self);
218 - (CPDecimal)decimalValue
220 throw new Error(
"decimalValue: NOT YET IMPLEMENTED");
226 return self.toString();
228 throw new Error(
"descriptionWithLocale: NOT YET IMPLEMENTED");
236 - (double)doubleValue
238 if (typeof
self ==
"boolean")
245 if (typeof
self ==
"boolean")
252 if (typeof
self ==
"boolean")
257 - (
long long)longLongValue
259 if (typeof
self ==
"boolean")
266 if (typeof
self ==
"boolean")
273 if (typeof
self ==
"boolean")
280 return self.toString();
283 - (
unsigned char)unsignedCharValue
285 return String.fromCharCode(
self);
288 - (
unsigned int)unsignedIntValue
290 if (typeof
self ==
"boolean")
301 - (
unsigned long)unsignedLongValue
303 if (typeof
self ==
"boolean")
308 - (
unsigned short)unsignedShortValue
310 if (typeof
self ==
"boolean")
317 if (aNumber === nil || aNumber[
'isa'] ===
CPNull)
322 else if (
self < aNumber)
330 return self == aNumber;
339 return [aCoder decodeNumber];
344 [aCoder encodeNumber:self forKey:@"self"];