#include <Number.h>
Inheritance diagram for Core::Number:
Public Member Functions | |
virtual String * | className (void) const |
Answer receiver class name. | |
virtual | operator long (void) const |
virtual long | asLong (void) const |
virtual | operator unsigned long (void) const |
virtual unsigned long | asUnsignedLong (void) const |
virtual | operator long long (void) const |
virtual long long | asLongLong (void) const abstract |
virtual | operator double (void) const |
virtual double | asDouble (void) const abstract |
virtual bool | isEqual (const Object *object) const abstract |
Compare receiver with given object. | |
virtual bool | isEqual (const Object &object) const |
Compare receiver with given object. | |
virtual bool | isEqual (int arg) const |
virtual bool | isEqual (double arg) const |
virtual bool | isEqualToDouble (double argument) const abstract |
virtual bool | isEqualToLongLong (long long argument) const abstract |
virtual Number * | negate (void) abstract |
virtual bool | isInteger (void) const |
virtual bool | isNegative (void) const |
Answer whether the receiver is negative. | |
virtual bool | isNumber (void) const |
Answer if the receiver is a Number. | |
virtual bool | isPositive (void) const abstract |
Answer whether the recevier is positive (including zero). | |
virtual bool | isReal (void) const |
virtual bool | isZero (void) const abstract |
Answer whether the receiver represents a zero in it's domain. | |
virtual void | visitBy (Visitor *visitor) |
Visit a number with the given visitor. | |
Static Public Member Functions | |
static Number * | fromString (String *str) |
Get a number from a string. | |
static Number * | fromStringRadix (String *str, int radix) |
|
Reimplemented in Core::Integer, and Core::Real. Referenced by operator double(). |
|
Definition at line 82 of file Number.cc. References asLongLong(). Referenced by Core::UCS2StreamEncoder::decodeFrom(), and operator long(). 00083 { 00084 return (long) asLongLong(); 00085 }
|
|
Reimplemented in Core::Integer, and Core::Real. Referenced by asLong(), asUnsignedLong(), Core::ByteArray::checkObject(), and operator long long(). |
|
Definition at line 92 of file Number.cc. References asLongLong(). Referenced by Core::Stream::nextPutBigEndianShort(), Core::Stream::nextPutLittleEndianLong(), Core::Stream::nextPutLittleEndianShort(), operator unsigned long(), and Core::Character::value(). 00093 { 00094 return (unsigned long) asLongLong(); 00095 }
|
|
Answer receiver class name. Because there isn't any standard way to obtain class name this method comes to place. Every class should rewrite this method but many didn't (yet). Reimplemented from Core::Object. Reimplemented in Core::Integer, and Core::Real. Definition at line 37 of file Number.cc. 00038 { 00039 return new String("Number"); 00040 }
|
|
Get a number from a string.
Definition at line 43 of file Number.cc. References fromStringRadix(). Referenced by Core::String::asNumber(). 00044 { 00045 return fromStringRadix(str, 0); 00046 }
|
|
Definition at line 48 of file Number.cc. References Core::String::asCString(), Core::Locale::current(), isEqual(), Core::Integer::value(), and Core::Real::value(). Referenced by Core::String::asNumberRadix(), and fromString(). 00049 { 00050 char *string = str->asCString(); 00051 char *end; 00052 long long integer; 00053 00054 integer = strtoll(string, &end, radix); 00055 if (end[0] == '.' || Locale::current()->decimalPoint()->isEqual(end[0])) { 00056 double real; 00057 end[0] = Locale::current()->decimalPoint()->asInteger(); 00058 real = strtod(string, NULL); 00059 return Real::value(real); 00060 } else { 00061 return Integer::value(integer); 00062 } 00063 }
|
|
Reimplemented in Core::Integer, and Core::Real. Definition at line 71 of file Number.cc. References isEqualToDouble(). 00072 { 00073 return this->isEqualToDouble(arg); 00074 }
|
|
Reimplemented in Core::Integer, and Core::Real. Definition at line 66 of file Number.cc. References isEqualToLongLong(). 00067 { 00068 return this->isEqualToLongLong(arg); 00069 }
|
|
Compare receiver with given object. Do not rewrite this method. It just a sugar for Object::isEqual(Object *).
Reimplemented from Core::Object. Reimplemented in Core::Integer, and Core::Real. Definition at line 65 of file Number.h. References Core::Object::isEqual(). 00066 { return Object::isEqual(object); }
|
|
Compare receiver with given object. This method could compare objects with more sophisticated algorithm (eg. based on instance variables comparing or so). If you rewrite this method you should rewrite hash() too.
Reimplemented from Core::Object. Reimplemented in Core::Integer, and Core::Real. Referenced by fromStringRadix(), Core::Real::isEqual(), and Core::Integer::isEqual(). |
|
Reimplemented in Core::Integer, and Core::Real. Referenced by isEqual(). |
|
Reimplemented in Core::Integer, and Core::Real. Referenced by isEqual(). |
|
Reimplemented in Core::Integer. Definition at line 108 of file Number.cc. 00109 { 00110 return false; 00111 }
|
|
Answer whether the receiver is negative.
Definition at line 113 of file Number.cc. References isPositive(). 00114 { 00115 return !isPositive(); 00116 }
|
|
Answer if the receiver is a Number.
Reimplemented from Core::Object. Definition at line 118 of file Number.cc. 00119 { 00120 return true; 00121 }
|
|
Answer whether the recevier is positive (including zero).
Reimplemented in Core::Integer, and Core::Real. Referenced by isNegative(). |
|
Reimplemented in Core::Real. Definition at line 123 of file Number.cc. 00124 { 00125 return false; 00126 }
|
|
Answer whether the receiver represents a zero in it's domain.
Reimplemented in Core::Integer, and Core::Real. |
|
Reimplemented in Core::Integer, and Core::Real. |
|
Definition at line 102 of file Number.cc. References asDouble(). 00103 { 00104 return asDouble(); 00105 }
|
|
Definition at line 77 of file Number.cc. References asLong(). 00078 { 00079 return asLong(); 00080 }
|
|
Definition at line 97 of file Number.cc. References asLongLong(). 00098 { 00099 return asLongLong(); 00100 }
|
|
Definition at line 87 of file Number.cc. References asUnsignedLong(). 00088 { 00089 return asUnsignedLong(); 00090 }
|
|
Visit a number with the given visitor.
Reimplemented from Core::Object. Definition at line 129 of file Number.cc. References Core::Visitor::visitNumber(). 00130 { 00131 visitor->visitNumber(this); 00132 }
|