changed: small changes especially cosmetic in documentation (commentaries)

changed: version of the library: now 0.8.2


git-svn-id: svn://ttmath.org/publicrep/ttmath/trunk@68 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2008-06-18 00:33:05 +00:00
parent 2933213a02
commit 98c2379182
12 changed files with 301 additions and 193 deletions

View File

@@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2006-2007, Tomasz Sowa
* Copyright (c) 2006-2008, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -275,6 +275,11 @@ namespace ttmath
*
*/
/*
this namespace consists of auxiliary functions
(something like 'private' in a class)
*/
namespace auxiliaryfunctions
{

View File

@@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2006-2007, Tomasz Sowa
* Copyright (c) 2006-2008, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -85,8 +85,10 @@ unsigned char info;
/*!
the number of a bit from 'info' which means that a value is with the sign
the number of a bit from 'info' which means that a value is with a sign
(when the bit is set)
/at the moment the rest bits from 'info' are not used/
*/
#define TTMATH_BIG_SIGN 128
@@ -149,7 +151,7 @@ public:
/*!
it sets value zero
this method sets zero
*/
void SetZero()
{
@@ -164,7 +166,7 @@ public:
/*!
it sets value one
this method sets one
*/
void SetOne()
{
@@ -173,7 +175,7 @@ public:
/*!
it sets value 0.5
this method sets value 0.5
*/
void Set05()
{
@@ -186,11 +188,11 @@ public:
private:
/*!
sets the mantissa of the value pi
this method sets the mantissa of the value of pi
*/
void SetMantissaPi()
{
// this is a static table which represents the value Pi (mantissa of it)
// this is a static table which represents the value of Pi (mantissa of it)
// (first is the highest word)
// we must define this table as 'unsigned int' because
// both on 32bit and 64bit platforms this table is 32bit
@@ -232,7 +234,7 @@ public:
/*!
sets the value of pi
this method sets the value of pi
*/
void SetPi()
{
@@ -243,7 +245,7 @@ public:
/*!
it sets value 0.5 * pi
this method sets the value of 0.5 * pi
*/
void Set05Pi()
{
@@ -254,7 +256,7 @@ public:
/*!
it sets value 2 * pi
this method sets the value of 2 * pi
*/
void Set2Pi()
{
@@ -265,7 +267,7 @@ public:
/*!
it sets value e
this method sets the value of e
(the base of the natural logarithm)
*/
void SetE()
@@ -305,8 +307,8 @@ public:
/*!
it sets value ln(2)
the natural logarithm from value 2
this method sets the value of ln(2)
the natural logarithm from 2
*/
void SetLn2()
{
@@ -346,8 +348,8 @@ public:
/*!
it sets value ln(10)
the natural logarithm from value 10
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
@@ -400,7 +402,7 @@ public:
/*!
it sets the maximum value which can be held in this type
this method sets the maximum value which can be held in this type
*/
void SetMax()
{
@@ -414,7 +416,7 @@ public:
/*!
it sets the minimum value which can be held in this type
this method sets the minimum value which can be held in this type
*/
void SetMin()
{
@@ -442,7 +444,7 @@ public:
/*!
it returns true when there's the sign set
this method returns true when there's the sign set
*/
bool IsSign() const
{
@@ -451,7 +453,7 @@ public:
/*!
it clears the sign
this method clears the sign
(there'll be an absolute value)
e.g.
@@ -465,7 +467,7 @@ public:
/*!
it remains the 'sign' of the value
this method remains the 'sign' of the value
e.g. -2 = -1
0 = 0
10 = 1
@@ -487,14 +489,14 @@ public:
/*!
it sets the sign
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 different from zero
you must be sure that the value is (or will be afterwards) different from zero
*/
void SetSign()
{
@@ -503,7 +505,7 @@ public:
/*!
it changes the sign
this method changes the sign
e.g.
-1 -> 1
@@ -933,7 +935,7 @@ public:
/*!
the remainder from the division
the remainder from a division
e.g.
12.6 mod 3 = 0.6 because 12.6 = 3*4 + 0.6
@@ -1545,7 +1547,7 @@ public:
/*!
this method sets 'result' as the one word of type uint
this method converts 'this' into 'result'
if the value is too big this method returns a carry (1)
*/
@@ -1588,7 +1590,7 @@ public:
/*!
this method sets 'result' as the one word of type sint
this method converts 'this' into 'result'
if the value is too big this method returns a carry (1)
*/
@@ -1618,7 +1620,7 @@ public:
/*!
this method sets the value in 'result'
this method converts 'this' into 'result'
if the value is too big this method returns a carry (1)
*/
@@ -3096,8 +3098,8 @@ public:
'source' - pointer to the string for parsing
if 'after_source' is set that when this method will have finished its job
it set the pointer to the new first character after this parsed value
if 'after_source' is set that when this method have finished its job
it set the pointer to the new first character after parsed value
*/
uint FromString(const char * source, uint base = 10, const char ** after_source = 0)
{

View File

@@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2006-2007, Tomasz Sowa
* Copyright (c) 2006-2008, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -208,7 +208,7 @@ private:
public:
/*!
this method adds two value with a sign and returns carry
this method adds two value with a sign and returns a carry
we're using methods from the base class because values are stored with U2
we must only make the carry correction
@@ -631,7 +631,7 @@ public:
/*!
the copy constructor
a copy constructor
*/
Int(const Int<value_size> & u)
{
@@ -790,6 +790,7 @@ public:
{
}
/*!
this method returns the lowest value from table with a sign

View File

@@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2006-2007, Tomasz Sowa
* Copyright (c) 2006-2008, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without

View File

@@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2006-2007, Tomasz Sowa
* Copyright (c) 2006-2008, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -439,7 +439,7 @@ void SkipWhiteCharacters()
/*!
a auxiliary method for RecurrenceParsingVariablesOrFunction(...)
an auxiliary method for RecurrenceParsingVariablesOrFunction(...)
*/
void RecurrenceParsingVariablesOrFunction_CheckStopCondition(bool variable, const std::string & name)
{
@@ -457,7 +457,7 @@ void RecurrenceParsingVariablesOrFunction_CheckStopCondition(bool variable, cons
/*!
a auxiliary method for RecurrenceParsingVariablesOrFunction(...)
an auxiliary method for RecurrenceParsingVariablesOrFunction(...)
*/
void RecurrenceParsingVariablesOrFunction_AddName(bool variable, const std::string & name)
{
@@ -468,7 +468,7 @@ void RecurrenceParsingVariablesOrFunction_AddName(bool variable, const std::stri
}
/*!
a auxiliary method for RecurrenceParsingVariablesOrFunction(...)
an auxiliary method for RecurrenceParsingVariablesOrFunction(...)
*/
void RecurrenceParsingVariablesOrFunction_DeleteName(bool variable, const std::string & name)
{
@@ -1277,7 +1277,7 @@ void CallFunction(const std::string & function_name, int amount_of_args, int sin
/*!
insert a function to the functions' table
inserting a function to the functions' table
function_name - name of the function
pf - pointer to the function (to the wrapper)
@@ -1289,7 +1289,7 @@ void InsertFunctionToTable(const std::string & function_name, pfunction pf)
/*!
insert a function to the variables' table
inserting a function to the variables' table
(this function returns value of variable)
variable_name - name of the function
@@ -1367,7 +1367,7 @@ void CreateFunctionsTable()
/*!
this method create the table of variables
this method creates the table of variables
*/
void CreateVariablesTable()
{
@@ -1380,7 +1380,7 @@ void CreateVariablesTable()
/*!
convert from a big letter to a small one
converting from a big letter to a small one
*/
int ToLowerCase(int c)
{

View File

@@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2006-2007, Tomasz Sowa
* Copyright (c) 2006-2008, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -65,7 +65,7 @@
#define TTMATH_MAJOR_VER 0
#define TTMATH_MINOR_VER 8
#define TTMATH_REVISION_VER 2
#define TTMATH_PRERELEASE_VER 1
#define TTMATH_PRERELEASE_VER 0
/*!

View File

@@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2006-2007, Tomasz Sowa
* Copyright (c) 2006-2008, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -52,6 +52,9 @@
/*!
\brief a namespace for the TTMath library
*/
namespace ttmath
{
@@ -69,8 +72,8 @@ class UInt
public:
/*!
buffer for this integer value
the first value (index 0) means the lowest word of this value
buffer for the integer value
table[0] - the lowest word of the value
*/
uint table[value_size];
@@ -117,7 +120,7 @@ public:
/*!
it returns the size of the table
this method returns the size of the table
*/
uint Size() const
{
@@ -126,17 +129,19 @@ public:
/*!
this method sets value zero
this method sets zero
*/
void SetZero()
{
// in the future here can be 'memset'
for(uint i=0 ; i<value_size ; ++i)
table[i] = 0;
}
/*!
this method sets value one
this method sets one
*/
void SetOne()
{
@@ -218,6 +223,8 @@ public:
}
/*!
*
* basic mathematic functions
@@ -225,14 +232,12 @@ public:
*/
/*!
this method adding ss2 to the this and adding carry if it's defined
adding ss2 to the this and adding carry if it's defined
(this = this + ss2 + c)
c must be zero or one (might be a bigger value than 1)
function returns carry (1) (if it was)
function returns carry (1) (if it has been)
*/
uint Add(const UInt<value_size> & ss2, uint c=0)
{
@@ -339,8 +344,8 @@ public:
/*!
this method adds one word (at a specific position)
and returns a carry (if it was)
adding one word (at a specific position)
and returning a carry (if it has been)
e.g.
@@ -355,7 +360,7 @@ public:
table[1] = 30 + 2;
table[2] = 5;
of course if there was a carry from table[3] it would be returned
of course if there was a carry from table[2] it would be returned
*/
uint AddInt(uint value, uint index = 0)
{
@@ -462,7 +467,7 @@ public:
/*!
this method adds only two unsigned words to the existing value
adding only two unsigned words to the existing value
and these words begin on the 'index' position
(it's used in the multiplication algorithm 2)
@@ -630,12 +635,12 @@ public:
/*!
this method's subtracting ss2 from the 'this' and subtracting
subtracting ss2 from the 'this' and subtracting
carry if it has been defined
(this = this - ss2 - c)
c must be zero or one (might be a bigger value than 1)
function returns carry (1) (if it was)
function returns carry (1) (if it has been)
*/
uint Sub(const UInt<value_size> & ss2, uint c=0)
{
@@ -1156,7 +1161,7 @@ private:
public:
/*!
this method moving all bits into the left side 'bits' times
moving all bits into the left side 'bits' times
return value <- this <- C
bits is from a range of <0, man * TTMATH_BITS_PER_UINT>
@@ -1253,7 +1258,7 @@ private:
public:
/*!
this method moving all bits into the right side 'bits' times
moving all bits into the right side 'bits' times
c -> this -> return value
bits is from a range of <0, man * TTMATH_BITS_PER_UINT>
@@ -1473,7 +1478,7 @@ public:
/*!
it sets the bit bit_index
setting the 'bit_index' bit
bit_index bigger or equal zero
*/
@@ -2659,7 +2664,7 @@ private:
public:
/*!
this method sets n firt bits to value zero
this method sets n first bits to value zero
For example:
let n=2 then if there's a value 111 (bin) there'll be '100' (bin)
@@ -2695,7 +2700,7 @@ public:
/*!
it returns true if the highest bit of the value is set
this method returns true if the highest bit of the value is set
*/
bool IsTheHighestBitSet() const
{
@@ -2704,7 +2709,7 @@ public:
/*!
it returns true if the lowest bit of the value is set
this method returns true if the lowest bit of the value is set
*/
bool IsTheLowestBitSet() const
{
@@ -2713,7 +2718,7 @@ public:
/*!
it returns true if the value is equal zero
this method returns true if the value is equal zero
*/
bool IsZero() const
{
@@ -2746,7 +2751,7 @@ public:
A -> 10
f -> 15
this method don't check whether c 'is' correct or not
this method don't check whether c is correct or not
*/
static uint CharToDigit(uint c)
{
@@ -3116,6 +3121,8 @@ public:
}
/*!
*
* methods for comparing
@@ -3123,6 +3130,14 @@ public:
*/
/*!
this method returns true if 'this' is smaller than 'l'
'index' is an index of the first word from will be the comparison performed
(note: we start the comparison from back - from the last word, when index is -1 /default/
it is automatically set into the last word)
I introduced it for some kind of optimization made in the second division algorithm (Div2)
*/
bool CmpSmaller(const UInt<value_size> & l, sint index = -1) const
{
sint i;
@@ -3145,6 +3160,15 @@ public:
/*!
this method returns true if 'this' is bigger than 'l'
'index' is an index of the first word from will be the comparison performed
(note: we start the comparison from back - from the last word, when index is -1 /default/
it is automatically set into the last word)
I introduced it for some kind of optimization made in the second division algorithm (Div2)
*/
bool CmpBigger(const UInt<value_size> & l, sint index = -1) const
{
sint i;
@@ -3166,6 +3190,13 @@ public:
}
/*!
this method returns true if 'this' is equal 'l'
'index' is an index of the first word from will be the comparison performed
(note: we start the comparison from back - from the last word, when index is -1 /default/
it is automatically set into the last word)
*/
bool CmpEqual(const UInt<value_size> & l, sint index = -1) const
{
sint i;
@@ -3183,6 +3214,15 @@ public:
return true;
}
/*!
this method returns true if 'this' is smaller than or equal 'l'
'index' is an index of the first word from will be the comparison performed
(note: we start the comparison from back - from the last word, when index is -1 /default/
it is automatically set into the last word)
*/
bool CmpSmallerEqual(const UInt<value_size> & l, sint index=-1) const
{
sint i;
@@ -3203,6 +3243,15 @@ public:
return true;
}
/*!
this method returns true if 'this' is bigger than or equal 'l'
'index' is an index of the first word from will be the comparison performed
(note: we start the comparison from back - from the last word, when index is -1 /default/
it is automatically set into the last word)
*/
bool CmpBiggerEqual(const UInt<value_size> & l, sint index=-1) const
{
sint i;
@@ -3224,7 +3273,9 @@ public:
}
//
/*
operators for comparising
*/
bool operator<(const UInt<value_size> & l) const
{
@@ -3232,7 +3283,6 @@ public:
}
bool operator>(const UInt<value_size> & l) const
{
return CmpBigger(l);
@@ -3245,7 +3295,6 @@ public:
}
bool operator!=(const UInt<value_size> & l) const
{
return !operator==(l);
@@ -3361,6 +3410,7 @@ public:
return *this;
}
/*!
Prefix operator e.g ++variable
*/

View File

@@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2006-2007, Tomasz Sowa
* Copyright (c) 2006-2008, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -983,4 +983,3 @@ namespace ttmath
#endif
} //namespace