#include <Number.h>
Inheritance diagram for util::Number:

Each subclass of Number wraps a certain primitive numeric type. Numbers are Computable, i.e. arithmetic operations can be performed on the classes.
Public Types | |
| typedef IntegerTemplate< char > | Char |
| A shorthand for a 8-bit integer. | |
| typedef IntegerTemplate< short > | Short |
| A shorthand for a 16-bit integer. | |
| typedef IntegerTemplate< int > | Integer |
| A shorthand for a 32-bit integer. | |
| typedef IntegerTemplate< long > | Long |
| A shorthand for a 64-bit integer. | |
| typedef FloatTemplate< float > | Float |
| A shorthand for a 32-bit floating point number. | |
| typedef FloatTemplate< double > | Double |
| A shorthand for a 64-bit floating point number. | |
Public Methods | |
| operator bool () const throw (ComputationException&) | |
| Typecast to bool returns true when doubleValue() returns != 0. | |
| SmartPtr< Computable > | complement () const throw (ComputationException&) |
| If a complement can be defined for this, then return it. | |
| operator char () const | |
| operator short () const | |
| operator int () const | |
| operator long () const | |
| operator float () const | |
| operator double () const | |
| virtual char | charValue () const=0 |
| virtual short | shortValue () const=0 |
| virtual int | intValue () const=0 |
| virtual long | longValue () const=0 |
| virtual float | floatValue () const=0 |
| virtual double | doubleValue () const=0 |
| SmartPtr< Computable > | plus (const Computable &c, bool switched=false) const throw (ComputationException&) |
| Calculate the sum of this and c. | |
| SmartPtr< Computable > | minus (const Computable &c) const throw (ComputationException&) |
| Calculate the difference of this and c. | |
| SmartPtr< Computable > | multiply (const Computable &c, bool switched=false) const throw (ComputationException&) |
| Calculate the product of this and c. | |
| SmartPtr< Computable > | divide (const Computable &c) const throw (ComputationException&) |
| Calculate the quotient of this and c. | |
| SmartPtr< Computable > | modulus (const Computable &c) const throw (ComputationException&) |
| Calculate the modulus of this and c. | |
| int | compare (const Computable &c) const throw (ComputationException&) |
| Compare two computable objects. | |
|
|
Compare two computable objects. This method should return a negative number, zero, or a positive number if c is larger than, equal to or smaller than this, respectively. Override this method if a simple one-dimensional comparison is sufficient for your custom type. If not, then you must override the less, greater etc. methods. Reimplemented from util::Computable. |
|
|
Calculate the quotient of this and c.
Reimplemented from util::Computable. |
|
|
Calculate the difference of this and c.
Reimplemented from util::Computable. |
|
|
Calculate the modulus of this and c.
Reimplemented from util::Computable. |
|
||||||||||||
|
Calculate the product of this and c.
Reimplemented from util::Computable. |
|
||||||||||||
|
Calculate the sum of this and c. Return a pointer to a newly allocated object which may be of any computable type. The caller is responsible for releasing the pointer. If switched is true, the result should be c + (this) instead of (this) + c, although for most types it should not make a difference. The switched helps developers as they do not need to implement the plus operation twice for any new type. The very same routine will calculate both String+Integer and Integer+String, for example, and there is no need to alter both classes.
Reimplemented from util::Computable. |