All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Public Attributes | Friends | List of all members
ttmath::Big< exp, man > Class Template Reference

Big implements the floating point numbers. More...

#include <ttmathbig.h>

Public Member Functions

uint CheckCarry (uint c)
 
uint Standardizing ()
 
void ClearInfoBit (unsigned char bit)
 
void SetInfoBit (unsigned char bit)
 
bool IsInfoBit (unsigned char bit) const
 
void SetZero ()
 
void SetOne ()
 
void Set05 ()
 
void SetNan ()
 
void SetZeroNan ()
 
void Swap (Big< exp, man > &ss2)
 
void SetPi ()
 
void Set05Pi ()
 
void Set2Pi ()
 
void SetE ()
 
void SetLn2 ()
 
void SetLn10 ()
 
void SetMax ()
 
void SetMin ()
 
bool IsZero () const
 
bool IsSign () const
 
bool IsNan () const
 
void Abs ()
 
void Sgn ()
 
void SetSign ()
 
void ChangeSign ()
 
uint Add (Big< exp, man > ss2, bool round=true, bool adding=true)
 
uint Sub (const Big< exp, man > &ss2, bool round=true)
 
uint BitAnd (Big< exp, man > ss2)
 
uint BitOr (Big< exp, man > ss2)
 
uint BitXor (Big< exp, man > ss2)
 
uint MulUInt (uint ss2)
 
uint MulInt (sint ss2)
 
uint Mul (const Big< exp, man > &ss2, bool round=true)
 
uint Div (const Big< exp, man > &ss2, bool round=true)
 
uint Mod (const Big< exp, man > &ss2)
 
uint Mod2 () const
 
template<uint pow_size>
uint Pow (UInt< pow_size > pow)
 
template<uint pow_size>
uint Pow (Int< pow_size > pow)
 
uint PowUInt (Big< exp, man > pow)
 
uint PowInt (const Big< exp, man > &pow)
 
uint PowFrac (const Big< exp, man > &pow)
 
uint Pow (const Big< exp, man > &pow)
 
uint Sqrt ()
 
uint Exp (const Big< exp, man > &x)
 
uint Ln (const Big< exp, man > &x)
 
uint Log (const Big< exp, man > &x, const Big< exp, man > &base)
 
template<uint another_exp, uint another_man>
uint FromBig (const Big< another_exp, another_man > &another)
 
uint ToUInt () const
 
uint ToUInt (uint &result) const
 
sint ToInt () const
 
uint ToInt (uint &result) const
 
uint ToInt (sint &result) const
 
template<uint int_size>
uint ToUInt (UInt< int_size > &result) const
 
template<uint int_size>
uint ToInt (UInt< int_size > &result) const
 
template<uint int_size>
uint ToInt (Int< int_size > &result) const
 
uint FromUInt (uint value)
 
uint FromInt (uint value)
 
uint FromInt (sint value)
 
uint FromDouble (double value)
 
uint FromFloat (float value)
 
double ToDouble () const
 
float ToFloat () const
 
uint ToFloat (float &result) const
 
uint ToDouble (double &result) const
 
Big< exp, man > & operator= (sint value)
 
Big< exp, man > & operator= (uint value)
 
Big< exp, man > & operator= (float value)
 
Big< exp, man > & operator= (double value)
 
 Big (sint value)
 
 Big (uint value)
 
 Big (double value)
 
 Big (float value)
 
uint ToUInt (ulint &result) const
 
uint ToInt (ulint &result) const
 
uint ToInt (slint &result) const
 
uint FromUInt (ulint value)
 
uint FromInt (ulint value)
 
uint FromInt (slint value)
 
 Big (ulint value)
 
Big< exp, man > & operator= (ulint value)
 
 Big (slint value)
 
Big< exp, man > & operator= (slint value)
 
template<uint int_size>
uint FromUInt (UInt< int_size > value)
 
template<uint int_size>
uint FromInt (const UInt< int_size > &value)
 
template<uint int_size>
uint FromInt (Int< int_size > value)
 
template<uint int_size>
Big< exp, man > & operator= (const Int< int_size > &value)
 
template<uint int_size>
 Big (const Int< int_size > &value)
 
template<uint int_size>
Big< exp, man > & operator= (const UInt< int_size > &value)
 
template<uint int_size>
 Big (const UInt< int_size > &value)
 
template<uint another_exp, uint another_man>
Big< exp, man > & operator= (const Big< another_exp, another_man > &value)
 
template<uint another_exp, uint another_man>
 Big (const Big< another_exp, another_man > &value)
 
 Big ()
 
 ~Big ()
 
Big< exp, man > & operator= (const Big< exp, man > &value)
 
 Big (const Big< exp, man > &value)
 
uint ToString (std::string &result, uint base=10, bool scient=false, sint scient_from=15, sint round=-1, bool trim_zeroes=true, char comma= '.') const
 
uint ToString (std::string &result, const Conv &conv) const
 
std::string ToString (const Conv &conv) const
 
std::string ToString (uint base=10) const
 
uint ToString (std::wstring &result, uint base=10, bool scient=false, sint scient_from=15, sint round=-1, bool trim_zeroes=true, wchar_t comma= '.') const
 
uint ToString (std::wstring &result, const Conv &conv) const
 
std::wstring ToWString (const Conv &conv) const
 
std::wstring ToWString (uint base=10) const
 
uint FromString (const char *source, uint base=10, const char **after_source=0, bool *value_read=0)
 
uint FromString (const char *source, const Conv &conv, const char **after_source=0, bool *value_read=0)
 
uint FromString (const std::string &string, uint base=10, const char **after_source=0, bool *value_read=0)
 
uint FromString (const std::string &string, const Conv &conv, const char **after_source=0, bool *value_read=0)
 
uint FromString (const wchar_t *source, uint base=10, const wchar_t **after_source=0, bool *value_read=0)
 
uint FromString (const wchar_t *source, const Conv &conv, const wchar_t **after_source=0, bool *value_read=0)
 
uint FromString (const std::wstring &string, uint base=10, const wchar_t **after_source=0, bool *value_read=0)
 
uint FromString (const std::wstring &string, const Conv &conv, const wchar_t **after_source=0, bool *value_read=0)
 
 Big (const char *string)
 
 Big (const std::string &string)
 
Big< exp, man > & operator= (const char *string)
 
Big< exp, man > & operator= (const std::string &string)
 
 Big (const wchar_t *string)
 
 Big (const std::wstring &string)
 
Big< exp, man > & operator= (const wchar_t *string)
 
Big< exp, man > & operator= (const std::wstring &string)
 
bool SmallerWithoutSignThan (const Big< exp, man > &ss2) const
 
bool GreaterWithoutSignThan (const Big< exp, man > &ss2) const
 
bool EqualWithoutSign (const Big< exp, man > &ss2) const
 
bool operator< (const Big< exp, man > &ss2) const
 
bool operator== (const Big< exp, man > &ss2) const
 
bool operator> (const Big< exp, man > &ss2) const
 
bool operator>= (const Big< exp, man > &ss2) const
 
bool operator<= (const Big< exp, man > &ss2) const
 
bool operator!= (const Big< exp, man > &ss2) const
 
Big< exp, man > operator- () const
 
Big< exp, man > operator- (const Big< exp, man > &ss2) const
 
Big< exp, man > & operator-= (const Big< exp, man > &ss2)
 
Big< exp, man > operator+ (const Big< exp, man > &ss2) const
 
Big< exp, man > & operator+= (const Big< exp, man > &ss2)
 
Big< exp, man > operator* (const Big< exp, man > &ss2) const
 
Big< exp, man > & operator*= (const Big< exp, man > &ss2)
 
Big< exp, man > operator/ (const Big< exp, man > &ss2) const
 
Big< exp, man > & operator/= (const Big< exp, man > &ss2)
 
Big< exp, man > & operator++ ()
 
Big< exp, man > operator++ (int)
 
Big< exp, man > & operator-- ()
 
Big< exp, man > operator-- (int)
 
Big< exp, man > operator& (const Big< exp, man > &p2) const
 
Big< exp, man > & operator&= (const Big< exp, man > &p2)
 
Big< exp, man > operator| (const Big< exp, man > &p2) const
 
Big< exp, man > & operator|= (const Big< exp, man > &p2)
 
Big< exp, man > operator^ (const Big< exp, man > &p2) const
 
Big< exp, man > & operator^= (const Big< exp, man > &p2)
 
void SkipFraction ()
 
void RemainFraction ()
 
bool IsInteger () const
 
uint Round ()
 

Static Public Member Functions

static const char * LibTypeStr ()
 
static LibTypeCode LibType ()
 

Public Attributes

Int< exp > exponent
 
UInt< man > mantissa
 
unsigned char info
 

Friends

class Big< exp-1, man >
 
std::ostream & operator<< (std::ostream &s, const Big< exp, man > &l)
 
std::wostream & operator<< (std::wostream &s, const Big< exp, man > &l)
 
std::istream & operator>> (std::istream &s, Big< exp, man > &l)
 
std::wistream & operator>> (std::wistream &s, Big< exp, man > &l)
 

Detailed Description

template<uint exp, uint man>
class ttmath::Big< exp, man >

Big implements the floating point numbers.

Constructor & Destructor Documentation

template<uint exp, uint man>
ttmath::Big< exp, man >::Big ( sint  value)
inline

a constructor for converting 'sint' to this class

template<uint exp, uint man>
ttmath::Big< exp, man >::Big ( uint  value)
inline

a constructor for converting 'uint' to this class

template<uint exp, uint man>
ttmath::Big< exp, man >::Big ( double  value)
inline

a constructor for converting 'double' to this class

template<uint exp, uint man>
ttmath::Big< exp, man >::Big ( float  value)
inline

a constructor for converting 'float' to this class

template<uint exp, uint man>
ttmath::Big< exp, man >::Big ( ulint  value)
inline

a constructor for converting 'ulint' (64bit unsigned integer) to this class

template<uint exp, uint man>
ttmath::Big< exp, man >::Big ( slint  value)
inline

a constructor for converting 'slint' (64bit signed integer) to this class

template<uint exp, uint man>
template<uint int_size>
ttmath::Big< exp, man >::Big ( const Int< int_size > &  value)
inline

a constructor for converting from 'Int<int_size>' to this class

template<uint exp, uint man>
template<uint int_size>
ttmath::Big< exp, man >::Big ( const UInt< int_size > &  value)
inline

a constructor for converting from 'UInt<int_size>' to this class

template<uint exp, uint man>
template<uint another_exp, uint another_man>
ttmath::Big< exp, man >::Big ( const Big< another_exp, another_man > &  value)
inline

a constructor for converting from 'Big<another_exp, another_man>' to this class

template<uint exp, uint man>
ttmath::Big< exp, man >::Big ( )
inline

a default constructor

by default we don't set any of the members to zero only NaN flag is set

if you want the mantissa and exponent to be set to zero define TTMATH_BIG_DEFAULT_CLEAR macro (useful for debug purposes)

template<uint exp, uint man>
ttmath::Big< exp, man >::~Big ( )
inline

a destructor

template<uint exp, uint man>
ttmath::Big< exp, man >::Big ( const Big< exp, man > &  value)
inline

a constructor for copying from another object of this class

template<uint exp, uint man>
ttmath::Big< exp, man >::Big ( const char *  string)
inline

a constructor for converting a string into this class

template<uint exp, uint man>
ttmath::Big< exp, man >::Big ( const std::string &  string)
inline

a constructor for converting a string into this class

template<uint exp, uint man>
ttmath::Big< exp, man >::Big ( const wchar_t *  string)
inline

a constructor for converting a string into this class

template<uint exp, uint man>
ttmath::Big< exp, man >::Big ( const std::wstring &  string)
inline

a constructor for converting a string into this class

Member Function Documentation

template<uint exp, uint man>
void ttmath::Big< exp, man >::Abs ( )
inline

this method clears the sign (there'll be an absolute value)

e.g.
-1 -> 1
2  -> 2
template<uint exp, uint man>
uint ttmath::Big< exp, man >::Add ( Big< exp, man >  ss2,
bool  round = true,
bool  adding = true 
)
inline

Addition this = this + ss2

it returns carry if the sum is too big

template<uint exp, uint man>
uint ttmath::Big< exp, man >::BitAnd ( Big< exp, man >  ss2)
inline

bitwise AND

this and ss2 must be >= 0 return values: 0 - ok 1 - carry 2 - this or ss2 was negative

template<uint exp, uint man>
uint ttmath::Big< exp, man >::BitOr ( Big< exp, man >  ss2)
inline

bitwise OR

this and ss2 must be >= 0 return values: 0 - ok 1 - carry 2 - this or ss2 was negative

template<uint exp, uint man>
uint ttmath::Big< exp, man >::BitXor ( Big< exp, man >  ss2)
inline

bitwise XOR

this and ss2 must be >= 0 return values: 0 - ok 1 - carry 2 - this or ss2 was negative

template<uint exp, uint man>
void ttmath::Big< exp, man >::ChangeSign ( )
inline

this method changes the sign when there is a value of zero then the sign is not changed

e.g.
-1 -> 1
2  -> -2
template<uint exp, uint man>
uint ttmath::Big< exp, man >::CheckCarry ( uint  c)
inline

this method sets NaN if there was a carry (and returns 1 in such a case)

c can be 0, 1 or other value different from zero

template<uint exp, uint man>
void ttmath::Big< exp, man >::ClearInfoBit ( unsigned char  bit)
inline

this method clears a specific bit in the 'info' variable

bit is one of: TTMATH_BIG_SIGN, TTMATH_BIG_NAN etc.

template<uint exp, uint man>
uint ttmath::Big< exp, man >::Div ( const Big< exp, man > &  ss2,
bool  round = true 
)
inline

division this = this / ss2

return value: 0 - ok 1 - carry (in a division carry can be as well) 2 - improper argument (ss2 is zero)

template<uint exp, uint man>
bool ttmath::Big< exp, man >::EqualWithoutSign ( const Big< exp, man > &  ss2) const
inline

this method performs the formula 'abs(this) == abs(ss2)' and returns the result

(in other words it treats 'this' and 'ss2' as values without a sign) we don't check the NaN flag

template<uint exp, uint man>
uint ttmath::Big< exp, man >::Exp ( const Big< exp, man > &  x)
inline

Exponent this = exp(x) = e^x

we're using the fact that our value is stored in form of: x = mantissa * 2^exponent then e^x = e^(mantissa* 2^exponent) or e^x = (e^mantissa)^(2^exponent)

'Exp' returns a carry if we can't count the result ('x' is too big)

template<uint exp, uint man>
template<uint another_exp, uint another_man>
uint ttmath::Big< exp, man >::FromBig ( const Big< another_exp, another_man > &  another)
inline

converting methods

converting from another type of a Big object

template<uint exp, uint man>
uint ttmath::Big< exp, man >::FromDouble ( double  value)
inline

this method converts from standard double into this class

standard double means IEEE-754 floating point value with 64 bits it is as follows (from http://www.psc.edu/general/software/packages/ieee/ieee.html):

The IEEE double precision floating point standard representation requires a 64 bit word, which may be represented as numbered from 0 to 63, left to right. The first bit is the sign bit, S, the next eleven bits are the exponent bits, 'E', and the final 52 bits are the fraction 'F':

S EEEEEEEEEEE FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 0 1 11 12 63

The value V represented by the word may be determined as follows:

If E=2047 and F is nonzero, then V=NaN ("Not a number") If E=2047 and F is zero and S is 1, then V=-Infinity If E=2047 and F is zero and S is 0, then V=Infinity If 0<E<2047 then V=(-1)**S * 2 ** (E-1023) * (1.F) where "1.F" is intended to represent the binary number created by prefixing F with an implicit leading 1 and a binary point. If E=0 and F is nonzero, then V=(-1)**S * 2 ** (-1022) * (0.F) These are "unnormalized" values. If E=0 and F is zero and S is 1, then V=-0 If E=0 and F is zero and S is 0, then V=0

template<uint exp, uint man>
uint ttmath::Big< exp, man >::FromFloat ( float  value)
inline

this method converts from float to this class

template<uint exp, uint man>
uint ttmath::Big< exp, man >::FromInt ( uint  value)
inline

a method for converting 'uint' to this class

template<uint exp, uint man>
uint ttmath::Big< exp, man >::FromInt ( sint  value)
inline

a method for converting 'sint' to this class

template<uint exp, uint man>
uint ttmath::Big< exp, man >::FromInt ( ulint  value)
inline

a method for converting 'ulint' (64bit unsigned integer) to this class

template<uint exp, uint man>
uint ttmath::Big< exp, man >::FromInt ( slint  value)
inline

a method for converting 'slint' (64bit signed integer) to this class

template<uint exp, uint man>
template<uint int_size>
uint ttmath::Big< exp, man >::FromInt ( const UInt< int_size > &  value)
inline

a method for converting from 'UInt<int_size>' to this class

template<uint exp, uint man>
template<uint int_size>
uint ttmath::Big< exp, man >::FromInt ( Int< int_size >  value)
inline

a method for converting from 'Int<int_size>' to this class

template<uint exp, uint man>
uint ttmath::Big< exp, man >::FromString ( const char *  source,
uint  base = 10,
const char **  after_source = 0,
bool *  value_read = 0 
)
inline

a method for converting a string into its value

it returns 1 if the value is too big – we cannot pass it into the range of our class Big<exp,man> (or if the base is incorrect)

that means only digits before the comma operator can make this value too big, all digits after the comma we can ignore

'source' - pointer to the string for parsing

if 'after_source' is set that when this method finishes it sets the pointer to the new first character after parsed value

'value_read' - if the pointer is provided that means the value_read will be true only when a value has been actually read, there can be situation where only such a string '-' or '+' will be parsed – 'after_source' will be different from 'source' but no value has been read (there are no digits) on other words if 'value_read' is true – there is at least one digit in the string

template<uint exp, uint man>
uint ttmath::Big< exp, man >::FromString ( const char *  source,
const Conv conv,
const char **  after_source = 0,
bool *  value_read = 0 
)
inline

a method for converting a string into its value

template<uint exp, uint man>
uint ttmath::Big< exp, man >::FromString ( const std::string &  string,
uint  base = 10,
const char **  after_source = 0,
bool *  value_read = 0 
)
inline

a method for converting a string into its value

template<uint exp, uint man>
uint ttmath::Big< exp, man >::FromString ( const std::string &  string,
const Conv conv,
const char **  after_source = 0,
bool *  value_read = 0 
)
inline

a method for converting a string into its value

template<uint exp, uint man>
uint ttmath::Big< exp, man >::FromString ( const wchar_t *  source,
uint  base = 10,
const wchar_t **  after_source = 0,
bool *  value_read = 0 
)
inline

a method for converting a string into its value

template<uint exp, uint man>
uint ttmath::Big< exp, man >::FromString ( const wchar_t *  source,
const Conv conv,
const wchar_t **  after_source = 0,
bool *  value_read = 0 
)
inline

a method for converting a string into its value

template<uint exp, uint man>
uint ttmath::Big< exp, man >::FromString ( const std::wstring &  string,
uint  base = 10,
const wchar_t **  after_source = 0,
bool *  value_read = 0 
)
inline

a method for converting a string into its value

template<uint exp, uint man>
uint ttmath::Big< exp, man >::FromString ( const std::wstring &  string,
const Conv conv,
const wchar_t **  after_source = 0,
bool *  value_read = 0 
)
inline

a method for converting a string into its value

template<uint exp, uint man>
uint ttmath::Big< exp, man >::FromUInt ( uint  value)
inline

a method for converting 'uint' to this class

template<uint exp, uint man>
uint ttmath::Big< exp, man >::FromUInt ( ulint  value)
inline

a method for converting 'ulint' (64bit unsigned integer) to this class

template<uint exp, uint man>
template<uint int_size>
uint ttmath::Big< exp, man >::FromUInt ( UInt< int_size >  value)
inline

a method for converting from 'UInt<int_size>' to this class

template<uint exp, uint man>
bool ttmath::Big< exp, man >::GreaterWithoutSignThan ( const Big< exp, man > &  ss2) const
inline

this method performs the formula 'abs(this) > abs(ss2)' and returns the result

(in other words it treats 'this' and 'ss2' as values without a sign) we don't check the NaN flag

template<uint exp, uint man>
bool ttmath::Big< exp, man >::IsInfoBit ( unsigned char  bit) const
inline

this method returns true if a specific bit in the 'info' variable is set

bit is one of: TTMATH_BIG_SIGN, TTMATH_BIG_NAN etc.

template<uint exp, uint man>
bool ttmath::Big< exp, man >::IsInteger ( ) const
inline

this method returns true if the value is integer (there is no a fraction)

(we don't check nan)

template<uint exp, uint man>
bool ttmath::Big< exp, man >::IsNan ( ) const
inline

this method returns true when there is not a valid number

template<uint exp, uint man>
bool ttmath::Big< exp, man >::IsSign ( ) const
inline

this method returns true when there's the sign set also we don't check the NaN flag

template<uint exp, uint man>
bool ttmath::Big< exp, man >::IsZero ( ) const
inline

testing whether there is a value zero or not

template<uint exp, uint man>
static LibTypeCode ttmath::Big< exp, man >::LibType ( )
inlinestatic

returning the currect type of the library

template<uint exp, uint man>
static const char* ttmath::Big< exp, man >::LibTypeStr ( )
inlinestatic

returning the string represents the currect type of the library we have following types: asm_vc_32 - with asm code designed for Microsoft Visual C++ (32 bits) asm_gcc_32 - with asm code designed for GCC (32 bits) asm_vc_64 - with asm for VC (64 bit) asm_gcc_64 - with asm for GCC (64 bit) no_asm_32 - pure C++ version (32 bit) - without any asm code no_asm_64 - pure C++ version (64 bit) - without any asm code

template<uint exp, uint man>
uint ttmath::Big< exp, man >::Ln ( const Big< exp, man > &  x)
inline

Natural logarithm this = ln(x) (a logarithm with the base equal 'e')

we're using the fact that our value is stored in form of: x = mantissa * 2^exponent then ln(x) = ln (mantissa * 2^exponent) = ln (mantissa) + (exponent * ln (2))

the mantissa we'll show as a value from range <1,2) because the logarithm is decreasing too fast when 'x' is going to 0

return values: 0 - ok 1 - overflow (carry) 2 - incorrect argument (x<=0)

template<uint exp, uint man>
uint ttmath::Big< exp, man >::Log ( const Big< exp, man > &  x,
const Big< exp, man > &  base 
)
inline

Logarithm from 'x' with a 'base'

we're using the formula: Log(x) with 'base' = ln(x) / ln(base)

return values: 0 - ok 1 - overflow 2 - incorrect argument (x<=0) 3 - incorrect base (a<=0 lub a=1)

template<uint exp, uint man>
uint ttmath::Big< exp, man >::Mod ( const Big< exp, man > &  ss2)
inline

the remainder from a division

e.g. 12.6 mod 3 = 0.6 because 12.6 = 3*4 + 0.6 -12.6 mod 3 = -0.6 bacause -12.6 = 3*(-4) + (-0.6) 12.6 mod -3 = 0.6 -12.6 mod -3 = -0.6

it means: in other words: this(old) = ss2 * q + this(new)

return value: 0 - ok 1 - carry 2 - improper argument (ss2 is zero)

template<uint exp, uint man>
uint ttmath::Big< exp, man >::Mod2 ( ) const
inline

this method returns: 'this' mod 2 (either zero or one)

this method is much faster than using Mod( object_with_value_two )

template<uint exp, uint man>
uint ttmath::Big< exp, man >::Mul ( const Big< exp, man > &  ss2,
bool  round = true 
)
inline

multiplication this = this * ss2 this method returns a carry

template<uint exp, uint man>
uint ttmath::Big< exp, man >::MulInt ( sint  ss2)
inline

Multiplication this = this * ss2 (ss2 is sint)

ss2 with a sign

template<uint exp, uint man>
uint ttmath::Big< exp, man >::MulUInt ( uint  ss2)
inline

Multiplication this = this * ss2 (ss2 is uint)

ss2 without a sign

template<uint exp, uint man>
bool ttmath::Big< exp, man >::operator!= ( const Big< exp, man > &  ss2) const
inline
template<uint exp, uint man>
Big<exp,man> ttmath::Big< exp, man >::operator& ( const Big< exp, man > &  p2) const
inline

bitwise operators (we do not define bitwise not)

template<uint exp, uint man>
Big<exp,man>& ttmath::Big< exp, man >::operator&= ( const Big< exp, man > &  p2)
inline
template<uint exp, uint man>
Big<exp,man> ttmath::Big< exp, man >::operator* ( const Big< exp, man > &  ss2) const
inline
template<uint exp, uint man>
Big<exp,man>& ttmath::Big< exp, man >::operator*= ( const Big< exp, man > &  ss2)
inline
template<uint exp, uint man>
Big<exp,man> ttmath::Big< exp, man >::operator+ ( const Big< exp, man > &  ss2) const
inline
template<uint exp, uint man>
Big<exp,man>& ttmath::Big< exp, man >::operator++ ( )
inline

Prefix operator e.g ++variable

template<uint exp, uint man>
Big<exp,man> ttmath::Big< exp, man >::operator++ ( int  )
inline

Postfix operator e.g variable++

template<uint exp, uint man>
Big<exp,man>& ttmath::Big< exp, man >::operator+= ( const Big< exp, man > &  ss2)
inline
template<uint exp, uint man>
Big<exp,man> ttmath::Big< exp, man >::operator- ( ) const
inline

standard mathematical operators

an operator for changing the sign

this method is not changing 'this' but the changed value is returned

template<uint exp, uint man>
Big<exp,man> ttmath::Big< exp, man >::operator- ( const Big< exp, man > &  ss2) const
inline
template<uint exp, uint man>
Big<exp,man>& ttmath::Big< exp, man >::operator-- ( )
inline
template<uint exp, uint man>
Big<exp,man> ttmath::Big< exp, man >::operator-- ( int  )
inline
template<uint exp, uint man>
Big<exp,man>& ttmath::Big< exp, man >::operator-= ( const Big< exp, man > &  ss2)
inline
template<uint exp, uint man>
Big<exp,man> ttmath::Big< exp, man >::operator/ ( const Big< exp, man > &  ss2) const
inline
template<uint exp, uint man>
Big<exp,man>& ttmath::Big< exp, man >::operator/= ( const Big< exp, man > &  ss2)
inline
template<uint exp, uint man>
bool ttmath::Big< exp, man >::operator< ( const Big< exp, man > &  ss2) const
inline
template<uint exp, uint man>
bool ttmath::Big< exp, man >::operator<= ( const Big< exp, man > &  ss2) const
inline
template<uint exp, uint man>
Big<exp, man>& ttmath::Big< exp, man >::operator= ( sint  value)
inline

an operator= for converting 'sint' to this class

template<uint exp, uint man>
Big<exp, man>& ttmath::Big< exp, man >::operator= ( uint  value)
inline

an operator= for converting 'uint' to this class

template<uint exp, uint man>
Big<exp, man>& ttmath::Big< exp, man >::operator= ( float  value)
inline

an operator= for converting 'float' to this class

template<uint exp, uint man>
Big<exp, man>& ttmath::Big< exp, man >::operator= ( double  value)
inline

an operator= for converting 'double' to this class

template<uint exp, uint man>
Big<exp, man>& ttmath::Big< exp, man >::operator= ( ulint  value)
inline

an operator for converting 'ulint' (64bit unsigned integer) to this class

template<uint exp, uint man>
Big<exp, man>& ttmath::Big< exp, man >::operator= ( slint  value)
inline

an operator for converting 'slint' (64bit signed integer) to this class

template<uint exp, uint man>
template<uint int_size>
Big<exp,man>& ttmath::Big< exp, man >::operator= ( const Int< int_size > &  value)
inline

an operator= for converting from 'Int<int_size>' to this class

template<uint exp, uint man>
template<uint int_size>
Big<exp,man>& ttmath::Big< exp, man >::operator= ( const UInt< int_size > &  value)
inline

an operator= for converting from 'UInt<int_size>' to this class

template<uint exp, uint man>
template<uint another_exp, uint another_man>
Big<exp,man>& ttmath::Big< exp, man >::operator= ( const Big< another_exp, another_man > &  value)
inline

an operator= for converting from 'Big<another_exp, another_man>' to this class

template<uint exp, uint man>
Big<exp,man>& ttmath::Big< exp, man >::operator= ( const Big< exp, man > &  value)
inline

the default assignment operator

template<uint exp, uint man>
Big<exp, man>& ttmath::Big< exp, man >::operator= ( const char *  string)
inline

an operator= for converting a string into its value

template<uint exp, uint man>
Big<exp, man>& ttmath::Big< exp, man >::operator= ( const std::string &  string)
inline

an operator= for converting a string into its value

template<uint exp, uint man>
Big<exp, man>& ttmath::Big< exp, man >::operator= ( const wchar_t *  string)
inline

an operator= for converting a string into its value

template<uint exp, uint man>
Big<exp, man>& ttmath::Big< exp, man >::operator= ( const std::wstring &  string)
inline

an operator= for converting a string into its value

template<uint exp, uint man>
bool ttmath::Big< exp, man >::operator== ( const Big< exp, man > &  ss2) const
inline
template<uint exp, uint man>
bool ttmath::Big< exp, man >::operator> ( const Big< exp, man > &  ss2) const
inline
template<uint exp, uint man>
bool ttmath::Big< exp, man >::operator>= ( const Big< exp, man > &  ss2) const
inline
template<uint exp, uint man>
Big<exp,man> ttmath::Big< exp, man >::operator^ ( const Big< exp, man > &  p2) const
inline
template<uint exp, uint man>
Big<exp,man>& ttmath::Big< exp, man >::operator^= ( const Big< exp, man > &  p2)
inline
template<uint exp, uint man>
Big<exp,man> ttmath::Big< exp, man >::operator| ( const Big< exp, man > &  p2) const
inline
template<uint exp, uint man>
Big<exp,man>& ttmath::Big< exp, man >::operator|= ( const Big< exp, man > &  p2)
inline
template<uint exp, uint man>
template<uint pow_size>
uint ttmath::Big< exp, man >::Pow ( UInt< pow_size >  pow)
inline

power this = this ^ pow (pow without a sign)

binary algorithm (r-to-l)

return values: 0 - ok 1 - carry 2 - incorrect arguments (0^0)

template<uint exp, uint man>
template<uint pow_size>
uint ttmath::Big< exp, man >::Pow ( Int< pow_size >  pow)
inline

power this = this ^ pow p can be negative

return values: 0 - ok 1 - carry 2 - incorrect arguments 0^0 or 0^(-something)

template<uint exp, uint man>
uint ttmath::Big< exp, man >::Pow ( const Big< exp, man > &  pow)
inline

power this = this ^ pow pow can be negative and with fraction

return values: 0 - ok 1 - carry 2 - incorrect argument ('this' or 'pow')

template<uint exp, uint man>
uint ttmath::Big< exp, man >::PowFrac ( const Big< exp, man > &  pow)
inline

power this = this ^ pow this must be greater than zero (this > 0) pow can be negative and with fraction

return values: 0 - ok 1 - carry 2 - incorrect argument ('this' <= 0)

template<uint exp, uint man>
uint ttmath::Big< exp, man >::PowInt ( const Big< exp, man > &  pow)
inline

power this = this ^ [pow] pow is treated as a value without a fraction pow can be negative

return values: 0 - ok 1 - carry 2 - incorrect arguments 0^0 or 0^(-something)

template<uint exp, uint man>
uint ttmath::Big< exp, man >::PowUInt ( Big< exp, man >  pow)
inline

power this = this ^ abs([pow]) pow is treated as a value without a sign and without a fraction if pow has a sign then the method pow.Abs() is used if pow has a fraction the fraction is skipped (not used in calculation)

return values: 0 - ok 1 - carry 2 - incorrect arguments (0^0)

template<uint exp, uint man>
void ttmath::Big< exp, man >::RemainFraction ( )
inline

this method remains only a fraction from the value

for example: 30.56 will be 0.56 -12.67 – -0.67

template<uint exp, uint man>
uint ttmath::Big< exp, man >::Round ( )
inline

this method rounds to the nearest integer value (it returns a carry if it was)

for example: 2.3 = 2 2.8 = 3

-2.3 = -2 -2.8 = 3

template<uint exp, uint man>
void ttmath::Big< exp, man >::Set05 ( )
inline

this method sets value 0.5

template<uint exp, uint man>
void ttmath::Big< exp, man >::Set05Pi ( )
inline

this method sets the value of 0.5 * pi

template<uint exp, uint man>
void ttmath::Big< exp, man >::Set2Pi ( )
inline

this method sets the value of 2 * pi

template<uint exp, uint man>
void ttmath::Big< exp, man >::SetE ( )
inline

this method sets the value of e (the base of the natural logarithm)

template<uint exp, uint man>
void ttmath::Big< exp, man >::SetInfoBit ( unsigned char  bit)
inline

this method sets a specific bit in the 'info' variable

bit is one of: TTMATH_BIG_SIGN, TTMATH_BIG_NAN etc.

template<uint exp, uint man>
void ttmath::Big< exp, man >::SetLn10 ( )
inline

this method sets the value of ln(10) the natural logarithm from 10

I introduced this constant especially to make the conversion ToString() being faster. In fact the method ToString() is keeping values of logarithms it has calculated but it must calculate the logarithm at least once. If a program, which uses this library, is running for a long time this would be ok, but for programs which are running shorter, for example for CGI applications which only once are printing values, this would be much inconvenience. Then if we're printing with base (radix) 10 and the mantissa of our value is smaller than or equal to TTMATH_BUILTIN_VARIABLES_SIZE we don't calculate the logarithm but take it from this constant.

template<uint exp, uint man>
void ttmath::Big< exp, man >::SetLn2 ( )
inline

this method sets the value of ln(2) the natural logarithm from 2

template<uint exp, uint man>
void ttmath::Big< exp, man >::SetMax ( )
inline

this method sets the maximum value which can be held in this type

template<uint exp, uint man>
void ttmath::Big< exp, man >::SetMin ( )
inline

this method sets the minimum value which can be held in this type

template<uint exp, uint man>
void ttmath::Big< exp, man >::SetNan ( )
inline

this method sets NaN flag (Not a Number) when this flag is set that means there is no a valid number

template<uint exp, uint man>
void ttmath::Big< exp, man >::SetOne ( )
inline

this method sets one

template<uint exp, uint man>
void ttmath::Big< exp, man >::SetPi ( )
inline

this method sets the value of pi

template<uint exp, uint man>
void ttmath::Big< exp, man >::SetSign ( )
inline

this method sets the sign

e.g.
-1 -> -1
2  -> -2

we do not check whether there is a zero or not, if you're using this method you must be sure that the value is (or will be afterwards) different from zero

template<uint exp, uint man>
void ttmath::Big< exp, man >::SetZero ( )
inline

this method sets zero

template<uint exp, uint man>
void ttmath::Big< exp, man >::SetZeroNan ( )
inline

this method sets NaN flag (Not a Number) also clears the mantissa and exponent (similarly as it would be a zero value)

template<uint exp, uint man>
void ttmath::Big< exp, man >::Sgn ( )
inline

this method remains the 'sign' of the value e.g. -2 = -1 0 = 0 10 = 1

template<uint exp, uint man>
void ttmath::Big< exp, man >::SkipFraction ( )
inline

this method makes an integer value by skipping any fractions

for example: 10.7 will be 10 12.1 – 12 -20.2 – 20 -20.9 – 20 -0.7 – 0 0.8 – 0

template<uint exp, uint man>
bool ttmath::Big< exp, man >::SmallerWithoutSignThan ( const Big< exp, man > &  ss2) const
inline

methods for comparing

this method performs the formula 'abs(this) < abs(ss2)' and returns the result

(in other words it treats 'this' and 'ss2' as values without a sign) we don't check the NaN flag

template<uint exp, uint man>
uint ttmath::Big< exp, man >::Sqrt ( )
inline

this function calculates the square root e.g. let this=9 then this.Sqrt() gives 3

return: 0 - ok 1 - carry 2 - improper argument (this<0 or NaN)

template<uint exp, uint man>
uint ttmath::Big< exp, man >::Standardizing ( )
inline

this method moves all bits from mantissa into its left side (suitably changes the exponent) or if the mantissa is zero it sets the exponent to zero as well (and clears the sign bit and sets the zero bit)

it can return a carry the carry will be when we don't have enough space in the exponent

you don't have to use this method if you don't change the mantissa and exponent directly

template<uint exp, uint man>
uint ttmath::Big< exp, man >::Sub ( const Big< exp, man > &  ss2,
bool  round = true 
)
inline

Subtraction this = this - ss2

it returns carry if the result is too big

template<uint exp, uint man>
void ttmath::Big< exp, man >::Swap ( Big< exp, man > &  ss2)
inline

this method swappes this for an argument

template<uint exp, uint man>
double ttmath::Big< exp, man >::ToDouble ( ) const
inline

this method converts from this class into the 'double'

if the value is too big: 'result' will be +/-infinity (depending on the sign) if the value is too small: 'result' will be 0

template<uint exp, uint man>
uint ttmath::Big< exp, man >::ToDouble ( double &  result) const
inline

this method converts from this class into the 'double'

if the value is too big: 'result' will be +/-infinity (depending on the sign) and the method returns 1 if the value is too small: 'result' will be 0 and the method returns 1

template<uint exp, uint man>
float ttmath::Big< exp, man >::ToFloat ( ) const
inline

this method converts from this class into the 'float'

if the value is too big: 'result' will be +/-infinity (depending on the sign) if the value is too small: 'result' will be 0

template<uint exp, uint man>
uint ttmath::Big< exp, man >::ToFloat ( float &  result) const
inline

this method converts from this class into the 'float'

if the value is too big: 'result' will be +/-infinity (depending on the sign) and the method returns 1 if the value is too small: 'result' will be 0 and the method returns 1

template<uint exp, uint man>
sint ttmath::Big< exp, man >::ToInt ( ) const
inline

this method converts 'this' into sint

template<uint exp, uint man>
uint ttmath::Big< exp, man >::ToInt ( uint result) const
inline

this method converts 'this' into 'result'

if the value is too big this method returns a carry (1)

template<uint exp, uint man>
uint ttmath::Big< exp, man >::ToInt ( sint result) const
inline

this method converts 'this' into 'result'

if the value is too big this method returns a carry (1)

template<uint exp, uint man>
template<uint int_size>
uint ttmath::Big< exp, man >::ToInt ( UInt< int_size > &  result) const
inline

this method converts 'this' into 'result'

if the value is too big this method returns a carry (1)

template<uint exp, uint man>
template<uint int_size>
uint ttmath::Big< exp, man >::ToInt ( Int< int_size > &  result) const
inline

this method converts 'this' into 'result'

if the value is too big this method returns a carry (1)

template<uint exp, uint man>
uint ttmath::Big< exp, man >::ToInt ( ulint result) const
inline

this method converts 'this' into 'result' (64 bit unsigned integer) if the value is too big this method returns a carry (1)

template<uint exp, uint man>
uint ttmath::Big< exp, man >::ToInt ( slint result) const
inline

this method converts 'this' into 'result' (64 bit unsigned integer) if the value is too big this method returns a carry (1)

template<uint exp, uint man>
uint ttmath::Big< exp, man >::ToString ( std::string &  result,
uint  base = 10,
bool  scient = false,
sint  scient_from = 15,
sint  round = -1,
bool  trim_zeroes = true,
char  comma = '.' 
) const
inline

a method for converting into a string struct Conv is defined in ttmathtypes.h, look there for more information about parameters

output: return value: 0 - ok and 'result' will be an object of type std::string (or std::wstring) which holds the value 1 - if there is a carry (it shoudn't be in a normal situation - if it is that means there is somewhere an error in the library)

template<uint exp, uint man>
uint ttmath::Big< exp, man >::ToString ( std::string &  result,
const Conv conv 
) const
inline

a method for converting into a string struct Conv is defined in ttmathtypes.h, look there for more information about parameters

template<uint exp, uint man>
std::string ttmath::Big< exp, man >::ToString ( const Conv conv) const
inline

a method for converting into a string struct Conv is defined in ttmathtypes.h, look there for more information about parameters

template<uint exp, uint man>
std::string ttmath::Big< exp, man >::ToString ( uint  base = 10) const
inline

a method for converting into a string struct Conv is defined in ttmathtypes.h, look there for more information about parameters

template<uint exp, uint man>
uint ttmath::Big< exp, man >::ToString ( std::wstring &  result,
uint  base = 10,
bool  scient = false,
sint  scient_from = 15,
sint  round = -1,
bool  trim_zeroes = true,
wchar_t  comma = '.' 
) const
inline

a method for converting into a string struct Conv is defined in ttmathtypes.h, look there for more information about parameters

template<uint exp, uint man>
uint ttmath::Big< exp, man >::ToString ( std::wstring &  result,
const Conv conv 
) const
inline

a method for converting into a string struct Conv is defined in ttmathtypes.h, look there for more information about parameters

template<uint exp, uint man>
uint ttmath::Big< exp, man >::ToUInt ( ) const
inline

this method converts 'this' into uint

template<uint exp, uint man>
uint ttmath::Big< exp, man >::ToUInt ( uint result) const
inline

this method converts 'this' into 'result'

if the value is too big this method returns a carry (1)

template<uint exp, uint man>
template<uint int_size>
uint ttmath::Big< exp, man >::ToUInt ( UInt< int_size > &  result) const
inline

this method converts 'this' into 'result'

if the value is too big this method returns a carry (1)

template<uint exp, uint man>
uint ttmath::Big< exp, man >::ToUInt ( ulint result) const
inline

this method converts 'this' into 'result' (64 bit unsigned integer) if the value is too big this method returns a carry (1)

template<uint exp, uint man>
std::wstring ttmath::Big< exp, man >::ToWString ( const Conv conv) const
inline

a method for converting into a string struct Conv is defined in ttmathtypes.h, look there for more information about parameters

template<uint exp, uint man>
std::wstring ttmath::Big< exp, man >::ToWString ( uint  base = 10) const
inline

a method for converting into a string struct Conv is defined in ttmathtypes.h, look there for more information about parameters

Friends And Related Function Documentation

template<uint exp, uint man>
friend class Big< exp-1, man >
friend

in the method 'ToString_CreateNewMantissaAndExponent()' we're using type 'Big<exp+1,man>' and we should have the ability to use some necessary methods from that class (methods which are private here)

template<uint exp, uint man>
std::ostream& operator<< ( std::ostream &  s,
const Big< exp, man > &  l 
)
friend

output to standard streams

template<uint exp, uint man>
std::wostream& operator<< ( std::wostream &  s,
const Big< exp, man > &  l 
)
friend

output to standard streams

template<uint exp, uint man>
std::istream& operator>> ( std::istream &  s,
Big< exp, man > &  l 
)
friend

input from standard streams

template<uint exp, uint man>
std::wistream& operator>> ( std::wistream &  s,
Big< exp, man > &  l 
)
friend

input from standard streams

Member Data Documentation

template<uint exp, uint man>
Int<exp> ttmath::Big< exp, man >::exponent
template<uint exp, uint man>
unsigned char ttmath::Big< exp, man >::info
template<uint exp, uint man>
UInt<man> ttmath::Big< exp, man >::mantissa

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