45 var result =
new Number();
46 result.isa = [
self class];
50 + (id)numberWithBool:(BOOL)aBoolean
52 return aBoolean ? 1 : 0;
55 + (id)numberWithChar:(
char)aChar
58 return aChar.charCodeAt(0);
63 + (id)numberWithDouble:(
double)aDouble
68 + (id)numberWithFloat:(
float)aFloat
73 + (id)numberWithInt:(
int)anInt
78 + (id)numberWithLong:(
long)aLong
83 + (id)numberWithLongLong:(
long long)aLongLong
88 + (id)numberWithShort:(
short)aShort
93 + (id)numberWithUnsignedChar:(
unsigned char)aChar
96 return aChar.charCodeAt(0);
101 + (id)numberWithUnsignedInt:(
unsigned)anUnsignedInt
103 return anUnsignedInt;
106 + (id)numberWithUnsignedLong:(
unsigned long)anUnsignedLong
108 return anUnsignedLong;
116 + (id)numberWithUnsignedShort:(
unsigned short)anUnsignedShort
118 return anUnsignedShort;
121 - (id)initWithBool:(BOOL)aBoolean
126 - (id)initWithChar:(
char)aChar
128 if (aChar.charCodeAt)
129 return aChar.charCodeAt(0);
134 - (id)initWithDouble:(
double)aDouble
139 - (id)initWithFloat:(
float)aFloat
144 - (id)initWithInt:(
int)anInt
149 - (id)initWithLong:(
long)aLong
154 - (id)initWithLongLong:(
long long)aLongLong
159 - (id)initWithShort:(
short)aShort
164 - (id)initWithUnsignedChar:(
unsigned char)aChar
166 if (aChar.charCodeAt)
167 return aChar.charCodeAt(0);
172 - (id)initWithUnsignedInt:(
unsigned)anUnsignedInt
174 return anUnsignedInt;
177 - (id)initWithUnsignedLong:(
unsigned long)anUnsignedLong
179 return anUnsignedLong;
187 - (id)initWithUnsignedShort:(
unsigned short)anUnsignedShort
189 return anUnsignedShort;
198 UID = objj_generateObjectUID();
208 return self ?
true :
false;
213 return String.fromCharCode(
self);
219 - (CPDecimal)decimalValue
221 throw new Error(
"decimalValue: NOT YET IMPLEMENTED");
227 return self.toString();
229 throw new Error(
"descriptionWithLocale: NOT YET IMPLEMENTED");
237 - (double)doubleValue
239 if (typeof
self ==
"boolean")
246 if (typeof
self ==
"boolean")
253 if (typeof
self ==
"boolean")
258 - (
long long)longLongValue
260 if (typeof
self ==
"boolean")
267 if (typeof
self ==
"boolean")
274 if (typeof
self ==
"boolean")
281 return self.toString();
284 - (
unsigned char)unsignedCharValue
286 return String.fromCharCode(
self);
289 - (
unsigned int)unsignedIntValue
291 if (typeof
self ==
"boolean")
302 - (
unsigned long)unsignedLongValue
304 if (typeof
self ==
"boolean")
309 - (
unsigned short)unsignedShortValue
311 if (typeof
self ==
"boolean")
318 if (aNumber === nil || aNumber[
'isa'] ===
CPNull)
323 else if (
self < aNumber)
331 return self == aNumber;
340 return [aCoder decodeNumber];
345 [aCoder encodeNumber:self forKey:@"self"];