Unified representation for all prices, amounts, sizes, volumes, etc. More...
Public Member Functions | |
ExponentialNumber () | |
Initialize default instance. | |
bool | zero () const |
Checks that number is zero. | |
void | makeZero () |
Assign zero. | |
bool | empty () const |
Note that 'empty' is special value which means that there are no numeric data. | |
void | makeEmpty () |
Make current instance empty. | |
bool | operator== (const ExponentialNumber &value) const |
Compare between book ids (equal to). | |
bool | operator!= (const ExponentialNumber &value) const |
Compare between book ids (not equal to). | |
bool | operator< (const ExponentialNumber &value) const |
Compare between book ids (less). | |
bool | operator> (const ExponentialNumber &value) const |
Compare between book ids (less). | |
Public Attributes | |
SInt32 | mantissa |
Mantissa. | |
SInt32 | exponent |
Power of 10. |
Unified representation for all prices, amounts, sizes, volumes, etc.
which present in HSVF specification.
DecimalNumber is quite similar to float/double storage with exception that exponent shows power of 10 (nor 2).
The exponent member has 32 bits just due to alignment issues, but it's possible to change it's content to represent multiplier (or divider) instead of exponent of 10.
I.e., instead of 5 it will be 100000, instead of -2 -- -100, etc. Positive number denotes multiplier, negative one - divider.
There is a sample of conversion to double (please don't use it in real code due to possibility to loose accuracy):
inline double toDouble(const ExponentialNumber &en) const { return double(en.mantissa) * pow(10.0, double(en.exponent)); }
bool empty | ( | ) | const [inline] |
Note that 'empty' is special value which means that there are no numeric data.
It is similar to NULL value in other programming languages.