Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

mcRealValue Class Reference

#include <Value.h>

Inheritance diagram for mcRealValue:

Inheritance graph
[legend]
Collaboration diagram for mcRealValue:

Collaboration graph
[legend]
List of all members.

Detailed Description

A real value like standard float and double types but with any desired precision kept during calculations.

Definition at line 653 of file Value.h.

Public Member Functions

 mcVALUE_DEFINE_CONSTRUCTORS (mcRealValue, mcMPF)
 mcRealValue (double f)
 mcRealValue (const mcRationalValue &m)
 mcRealValue (const mcIntegerValue &m)
mcRealValue pow (unsigned long n) const
mcRealValue pow (int n) const
mcRealValue pow (double n) const
mcRealValue pow (const mcRealValue &n) const
mcRealValue root (const mcRealValue &n)
mcRealValue abs () const
mcRealValue floor () const
mcRealValue ceil () const
mcRealValue trunc () const
bool isInteger () const
 Returns TRUE if all the approximation functions (floor, ceil, trunc) return the same value.
mcRealValue GetReciprocal () const
 Returns the reciprocal of this number.
 mcVALUE_DEFINE_ALLOPERATORS (mcRealValue, mcMPF, mpf)
 mcVALUE_DEFINE_DOUBLEOPERATORS (mcRealValue, mcMPF, mpf)
 mcVALUE_DEFINE_GETSET (mcRealValue, mpf)
 mcVALUE_DEFINE_FLAGSCOMPARISON_OPERATORS (mcIntegerValue, mpf_cmp_si, m.GetLong())
wxString GetStr () const
 See mcValue::GetStr.
wxString GetStr (int digits) const
virtual wxString GetExtStr (int digits=mcVALUE_DEFAULTPRECISION) const
 Returns a string in extended form:.
virtual wxString GetSmartStr (int threshold=mcVALUE_SMARTSTR_THRESHOLD, int digits=mcVALUE_DEFAULTPRECISION) const
 Returns a string in exponential form, if the exponent is greater than mcVALUE_SMARTSTR_THRESHOLD; returns a string in extended form if the exponent is less than mcVALUE_SMARTSTR_THRESHOLD.
double GetDouble () const
void SetDouble (double n)
mcRealValueoperator= (double d)
 operator double () const
int GetNumOfDigits (int digits=mcVALUE_DEFAULTPRECISION) const
mcRealValue GetFromDigitRange (int begin, int end=-1, int digits=mcVALUE_DEFAULTPRECISION) const
mcRealValue DeleteDigit (int pos, int digits=mcVALUE_DEFAULTPRECISION) const
mcRealValue InsertDigit (wxChar digit, int pos, int digits=mcVALUE_DEFAULTPRECISION) const
mcRealValue AppendDigit (wxChar digit, int digits=mcVALUE_DEFAULTPRECISION) const

Static Public Attributes

static mcRealValuepOne = NULL
static mcRealValuepZero = NULL
static mcRealValuepNAN = NULL
 Not a number. See isValid().
static mcRealValuepPosInf = NULL
 Positive infinite. See math_isFinite().
static mcRealValuepNegInf = NULL
 Negative infinite. See math_isFinite().

Protected Member Functions

wxString GetBaseStr (int *p, int digits, int *n) const
 Returns a raw string, not elaborated, as GMP returns.

Private Member Functions

 mcVALUE_DEFINE_COW (mcMPF, mpf)


Constructor & Destructor Documentation

mcRealValue::mcRealValue double  f  )  [inline]
 

Definition at line 672 of file Value.h.

References SetDouble().

Referenced by DeleteDigit(), GetFromDigitRange(), and InsertDigit().

mcRealValue::mcRealValue const mcRationalValue m  )  [inline]
 

Definition at line 673 of file Value.h.

mcRealValue::mcRealValue const mcIntegerValue m  )  [inline]
 

Definition at line 674 of file Value.h.


Member Function Documentation

mcRealValue mcRealValue::abs  )  const [inline]
 

Definition at line 690 of file Value.h.

Referenced by mcBisectSolver::math_Bisect().

mcRealValue mcRealValue::AppendDigit wxChar  digit,
int  digits = mcVALUE_DEFAULTPRECISION
const [inline]
 

Definition at line 754 of file Value.h.

References InsertDigit().

mcRealValue mcRealValue::ceil  )  const [inline]
 

Definition at line 692 of file Value.h.

mcRealValue mcRealValue::DeleteDigit int  pos,
int  digits = mcVALUE_DEFAULTPRECISION
const
 

Definition at line 376 of file Value.cpp.

References GetSmartStr(), mcASSERT, and mcRealValue().

mcRealValue mcRealValue::floor  )  const [inline]
 

Definition at line 691 of file Value.h.

Referenced by mcRationalValue::MakeInteger().

wxString mcRealValue::GetBaseStr int *  p,
int  digits,
int *  n
const [protected]
 

Returns a raw string, not elaborated, as GMP returns.

Definition at line 258 of file Value.cpp.

References GMP2WX.

Referenced by GetExtStr(), GetSmartStr(), and GetStr().

double mcRealValue::GetDouble  )  const [inline]
 

Definition at line 732 of file Value.h.

Referenced by mcFunctionHelpers::math_EvaluateBase(), operator double(), and pow().

wxString mcRealValue::GetExtStr int  digits = mcVALUE_DEFAULTPRECISION  )  const [virtual]
 

Returns a string in extended form:.

Snnnnnnnnnnnnnnnnnnnn example: -4318384739357974916

This function uses GetStr() and then "unroll" the trailer exponent adding the required zeroes at the end/begin of the number (for positive/ negative exponents) and the dot.

Note:
This function could take a *lot* of memory for big big numbers (like 123E+10000) and this can mean DoS (Denial Of Service): use with care !!!

Definition at line 328 of file Value.cpp.

References GetBaseStr().

mcRealValue mcRealValue::GetFromDigitRange int  begin,
int  end = -1,
int  digits = mcVALUE_DEFAULTPRECISION
const
 

Definition at line 339 of file Value.cpp.

References GetSmartStr(), and mcRealValue().

int mcRealValue::GetNumOfDigits int  digits = mcVALUE_DEFAULTPRECISION  )  const
 

Definition at line 352 of file Value.cpp.

References GetSmartStr().

Referenced by mcNumberHelpers::gui_BaseMoveCursor(), mcNumberHelpers::gui_BaseMoveCursorUsingPoint(), mcNumberHelpers::gui_EditBase(), mcNumberHelpers::gui_MergeWith(), and mcNumberHelpers::math_GetBaseLenght().

mcRealValue mcRealValue::GetReciprocal  )  const [inline]
 

Returns the reciprocal of this number.

Definition at line 700 of file Value.h.

wxString mcRealValue::GetSmartStr int  threshold = mcVALUE_SMARTSTR_THRESHOLD,
int  digits = mcVALUE_DEFAULTPRECISION
const [virtual]
 

Returns a string in exponential form, if the exponent is greater than mcVALUE_SMARTSTR_THRESHOLD; returns a string in extended form if the exponent is less than mcVALUE_SMARTSTR_THRESHOLD.

Definition at line 299 of file Value.cpp.

References GetBaseStr().

Referenced by DeleteDigit(), GetFromDigitRange(), GetNumOfDigits(), mcNumberHelpers::gui_GetStr(), InsertDigit(), and mcNumberHelpers::io_GetBaseInlinedExpr().

wxString mcRealValue::GetStr int  digits  )  const
 

Definition at line 275 of file Value.cpp.

References GetBaseStr().

wxString mcRealValue::GetStr  )  const [inline, virtual]
 

See mcValue::GetStr.

Implements mcValue.

Definition at line 710 of file Value.h.

References mcVALUE_DEFAULTPRECISION.

Referenced by mcRationalValue::GetStr(), mcNumberHelpers::math_DivideBaseOnlyBy(), and mcNumberHelpers::math_RaiseTo().

mcRealValue mcRealValue::InsertDigit wxChar  digit,
int  pos,
int  digits = mcVALUE_DEFAULTPRECISION
const
 

Definition at line 359 of file Value.cpp.

References GetSmartStr(), and mcRealValue().

Referenced by AppendDigit().

bool mcRealValue::isInteger  )  const [inline, virtual]
 

Returns TRUE if all the approximation functions (floor, ceil, trunc) return the same value.

Implements mcValue.

Definition at line 697 of file Value.h.

Referenced by mcRationalValue::GetFractionalDigitCount(), mcRationalValue::MakeInteger(), mcNumberHelpers::math_CanBeDivBy(), mcNumberHelpers::math_DivideBaseOnlyBy(), and mcNumberHelpers::math_GetGCD().

mcRealValue::mcVALUE_DEFINE_ALLOPERATORS mcRealValue  ,
mcMPF  ,
mpf 
 

mcRealValue::mcVALUE_DEFINE_CONSTRUCTORS mcRealValue  ,
mcMPF 
 

mcRealValue::mcVALUE_DEFINE_COW mcMPF  ,
mpf 
[private]
 

mcRealValue::mcVALUE_DEFINE_DOUBLEOPERATORS mcRealValue  ,
mcMPF  ,
mpf 
 

mcRealValue::mcVALUE_DEFINE_FLAGSCOMPARISON_OPERATORS mcIntegerValue  ,
mpf_cmp_si  ,
m.  GetLong()
 

mcRealValue::mcVALUE_DEFINE_GETSET mcRealValue  ,
mpf 
 

mcRealValue::operator double  )  const [inline]
 

Definition at line 736 of file Value.h.

References GetDouble().

mcRealValue& mcRealValue::operator= double  d  )  [inline]
 

Definition at line 735 of file Value.h.

References SetDouble().

mcRealValue mcRealValue::pow const mcRealValue n  )  const [inline]
 

Definition at line 685 of file Value.h.

References pow().

mcRealValue mcRealValue::pow double  n  )  const [inline]
 

Definition at line 683 of file Value.h.

References GetDouble(), pow(), and SetDouble().

mcRealValue mcRealValue::pow int  n  )  const [inline]
 

Definition at line 681 of file Value.h.

mcRealValue mcRealValue::pow unsigned long  n  )  const [inline]
 

Definition at line 679 of file Value.h.

Referenced by mcNumberHelpers::gui_MergeWith(), mcRationalValue::MakeInteger(), mcExpElementHelpers::math_Evaluate(), mcNumberHelpers::math_RaiseTo(), pow(), and root().

mcRealValue mcRealValue::root const mcRealValue n  )  [inline]
 

Definition at line 687 of file Value.h.

References pow().

Referenced by mcRadicalHelpers::math_Evaluate().

void mcRealValue::SetDouble double  n  )  [inline]
 

Definition at line 733 of file Value.h.

Referenced by mcRealValue(), operator=(), and pow().

mcRealValue mcRealValue::trunc  )  const [inline]
 

Definition at line 693 of file Value.h.


Member Data Documentation

mcRealValue * mcRealValue::pNAN = NULL [static]
 

Not a number. See isValid().

Definition at line 63 of file Value.cpp.

mcRealValue * mcRealValue::pNegInf = NULL [static]
 

Negative infinite. See math_isFinite().

Definition at line 65 of file Value.cpp.

mcRealValue * mcRealValue::pOne = NULL [static]
 

Definition at line 61 of file Value.cpp.

mcRealValue * mcRealValue::pPosInf = NULL [static]
 

Positive infinite. See math_isFinite().

Definition at line 64 of file Value.cpp.

mcRealValue * mcRealValue::pZero = NULL [static]
 

Definition at line 62 of file Value.cpp.


The documentation for this class was generated from the following files:

Documentation generated with Doxygen on Sun Feb 6 17:13:09 2005
Visit MathStudio home page for more info

[ Top ]