#include <Value.h>
Inheritance diagram for mcRationalValue:
Thus, numbers like 2/3 = 0.6666... can be stored without rounding and be approximated to any desired precision.
Definition at line 583 of file Value.h.
Public Member Functions | |
mcVALUE_DEFINE_CONSTRUCTORS (mcRationalValue, mcMPQ) | |
mcRationalValue (const mcIntegerValue &m) | |
mcRationalValue (const mcRealValue &m) | |
mcRationalValue (const mcIntegerValue &num, const mcIntegerValue &den) | |
mcIntegerValue | GetDen () const |
mcIntegerValue | GetNum () const |
void | Canonicalize () |
Remove any factors that are common to the numerator and denominator and make the denominator positive. | |
mcVALUE_DEFINE_SETGET_FLAGS () | |
mcVALUE_DEFINE_MISCELLANEOUS (mcRationalValue, mpq) | |
void | SetLong (long n) |
void | SetDouble (double n) |
void | SetStr (const wxString &str, int base=10) |
double | GetDouble () const |
long | GetLong () const |
wxString | GetStr () const |
See mcValue::GetStr. | |
bool | isInteger () const |
Returns TRUE if the denominator of this number is 1. | |
mcRationalValue | abs () const |
Returns the absolute value of this number. | |
mcRationalValue | GetFractionalPart () const |
Returns the fractional part of this number, removing the integer one. | |
int | GetFractionalDigitCount (int digits=mcVALUE_DEFAULTPRECISION) const |
Returns the number of fractional digits. | |
mcIntegerValue | GetIntegerPart () const |
Returns the integer part of this number, removing the fractional one. | |
mcIntegerValue | MakeInteger (int digits=mcVALUE_DEFAULTPRECISION) const |
Transform a copy of this number multiplying it by 10^GetFractionalDigitCount(*this), thus transforming it into an integer number. | |
Private Member Functions | |
mcVALUE_DEFINE_COW (mcMPQ, mpq) |
|
|
|
|
|
|
|
Returns the absolute value of this number.
|
|
Remove any factors that are common to the numerator and denominator and make the denominator positive.
Definition at line 601 of file Value.h. Referenced by mcNumberHelpers::math_GetNumDen(). |
|
Definition at line 594 of file Value.h. Referenced by isInteger(), and mcNumberHelpers::math_GetNumDen(). |
|
Definition at line 615 of file Value.h. Referenced by GetLong(). |
|
Returns the number of fractional digits.
Definition at line 199 of file Value.cpp. References mcRealValue::isInteger(). Referenced by MakeInteger(). |
|
Returns the fractional part of this number, removing the integer one. This function just subtracts the denominator from the numerator while the numerator is less than the denominator: 5/3 = 1.66666666666 ... . 2/3 = 0.66666666666 ... 19/13 = 1,461538461538461 . 6/13 = 0,461538461538461 |
|
Returns the integer part of this number, removing the fractional one. This function just subtracts to this number the value returned by GetFractionalPart(). |
|
Implements mcValue. Definition at line 616 of file Value.h. References GetDouble(). |
|
Definition at line 596 of file Value.h. Referenced by mcNumberHelpers::math_GetNumDen(). |
|
See mcValue::GetStr.
Implements mcValue. Definition at line 181 of file Value.cpp. References mcRealValue::GetStr(). |
|
Returns TRUE if the denominator of this number is 1.
Implements mcValue. Definition at line 622 of file Value.h. References GetDen(). Referenced by MakeInteger(). |
|
Transform a copy of this number multiplying it by 10^GetFractionalDigitCount(*this), thus transforming it into an integer number.
Definition at line 222 of file Value.cpp. References mcRealValue::floor(), GetFractionalDigitCount(), isInteger(), mcRealValue::isInteger(), mcASSERT, and mcRealValue::pow(). |
|
|
|
|
|
|
|
|
|
|
|
Implements mcValue. |
|
Implements mcValue. Definition at line 612 of file Value.h. References WX2GMP. |
[ Top ] |