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:
Tomasz Sowa 2008-06-18 00:33:05 +00:00
parent 2933213a02
commit 98c2379182
12 changed files with 301 additions and 193 deletions

269
CHANGELOG
View File

@ -1,122 +1,171 @@
Version 0.8.2 (2008.06.18):
* added: UInt::BitNot2() this method has been proposed by
Arek <kmicicc AnTispam users.sourceforge.net>
* changed: Int::FromInt(const Int<argument_size> & p),
Int::FromInt(sint value) (it returns zero now)
Int::operator=(uint i)
Int::Int(uint i)
* added: Int::FromUInt(const UInt<argument_size> & p),
Int::FromUInt(uint value)
and appropriate constructors and assignment
operators as well
* changed: Big::FromInt(Int<int_size> value),
* added: Big::FromUInt(UInt<int_size> value),
Big::operator=(const UInt<int_size> & value)
Big::Big(const UInt<int_size> & value)
* changed: the parser is allowed to recognize values which
begin with a dot, e.g '.5' is treated as '0.5'
* added: a method Big::FromDouble(double) which converts from
standard double into a Big
* added: uint Big::ToDouble(double&) - converting into double
* added: Big::FromBig() and an operator= and a contructor
for converting from another kind of a Big class
* added: to the parser: avg(), sum()
* added: 'decimal_point' parameter into Big::ToString(...)
* fixed: Big::operator>> didn't use TTMATH_COMMA_CHARACTER_2 macro
* added: a short form of multiplication (without the '*' character)
e.g. '5y', (it's used only if the second parameter
is a variable or function)
* changed: variables and functions are case-sensitive now
* added: variables and functions can have underline characters
in their names
* changed: 'max_digit_after_comma' in Big::ToString()
remove the -2 state
* added: 'remove_trailing_zeroes' in Big::ToString()
it's either true or false
* fixed/changed: the way of using Big::SetSign()
the method do not check whether there is a zero or not now
(even if there's a zero the method can set a sign bit)
I changed this due to some prior errors
(errors corrected in revision 17, 49 and 58)
Version 0.8.1 (2007.04.17):
* fixed: Big::PowFrac(..) didn't return a correct error code
(when 'this' was negative)
* added: Root(x; index) (and to the parser as well)
* added: macro: TTMATH_PRERELEASE_VER (can be either zero or one)
* added: UInt::MulInt(int, UInt<int another_size>::&)
* added: Big::MulUInt(uint)
* changed: Big::MulInt(sint)
* added: Big::ToUInt(uint &)
* changed: Big::ToInt(sint&)
* changed: Factorial() it uses Big::MulUInt() at the beginning
(faster now especially more on a 32bit platform)
* added: doxygen.cfg for generating a documentation from the doxygen
* changed: UInt::Rcl(uint c=0) and UInt::Rcr(uint c=0) into
UInt::Rcl2(uint bits, uint c) and UInt::Rcr2(uint bits, uint c)
now they can move more than one bit and they are only private
* fixed: UInt::Rcl(uint bits, uint c) and UInt::Rcr(uint bits, uint c)
didn't correctly return a carry if the 'bits' were equal
to 'value_size*TTMATH_BITS_PER_UINT'
* changed: UInt::Rcl(uint bits, uint c) and UInt::Rcr(uint bits, uint c)
into UInt::Rcl(uint bits, uint c=0) and
UInt::Rcr(uint bits, uint c=0)
they are faster now when the bits is greater than a half of
the TTMATH_BITS_PER_UINT
* changed: UInt::CompensationToLeft() it's faster now
* changed: more small changes where there were UInt::Rcl(uint c=0) and
UInt::Rcr(uint c=0) used
* changed: as the Big type uses UInt::Rcl() and UInt::Rcr() a lot then
it is much faster now (about 5-25%)
* added: ASinh(), ACosh(), ATanh() /ATgh()/, ACoth() /ACtgh()/
and to the parser as well
* added: UInt::BitAnd(), UInt::BitOr(), UInt::BitXor(), UInt::BitNot(),
Big::BitAnd(), Big::BitOr(), Big::BitXor()
* added: to the parser: bitand(), bitor(), bitxor()
/band(), bor(), bxor()/
* changed: the way of parsing operators in the mathematical parser
(the parser is not too much greedy now)
* fixed: Big::PowFrac(..) didn't return a correct error code
(when 'this' was negative)
* added: Root(x; index) (and to the parser as well)
* added: macro: TTMATH_PRERELEASE_VER (can be either zero or one)
* added: UInt::MulInt(int, UInt<int another_size>::&)
* added: Big::MulUInt(uint)
* changed: Big::MulInt(sint)
* added: Big::ToUInt(uint &)
* changed: Big::ToInt(sint&)
* changed: Factorial() it uses Big::MulUInt() at the beginning
(faster now especially more on a 32bit platform)
* added: doxygen.cfg for generating a documentation from the doxygen
* changed: UInt::Rcl(uint c=0) and UInt::Rcr(uint c=0) into
UInt::Rcl2(uint bits, uint c) and UInt::Rcr2(uint bits, uint c)
now they can move more than one bit and they are only private
* fixed: UInt::Rcl(uint bits, uint c) and UInt::Rcr(uint bits, uint c)
didn't correctly return a carry if the 'bits' were equal
to 'value_size*TTMATH_BITS_PER_UINT'
* changed: UInt::Rcl(uint bits, uint c) and UInt::Rcr(uint bits, uint c)
into UInt::Rcl(uint bits, uint c=0) and
UInt::Rcr(uint bits, uint c=0)
they are faster now when the bits is greater than a half of
the TTMATH_BITS_PER_UINT
* changed: UInt::CompensationToLeft() it's faster now
* changed: more small changes where there were UInt::Rcl(uint c=0) and
UInt::Rcr(uint c=0) used
* changed: as the Big type uses UInt::Rcl() and UInt::Rcr() a lot then
it is much faster now (about 5-25%)
* added: ASinh(), ACosh(), ATanh() /ATgh()/, ACoth() /ACtgh()/
and to the parser as well
* added: UInt::BitAnd(), UInt::BitOr(), UInt::BitXor(), UInt::BitNot(),
Big::BitAnd(), Big::BitOr(), Big::BitXor()
* added: to the parser: bitand(), bitor(), bitxor()
/band(), bor(), bxor()/
* changed: the way of parsing operators in the mathematical parser
(the parser is not too much greedy now)
Version 0.8.0 (2007.03.28):
* added: into the parser: SetFactorialMax()
* added: DegToDeg(deg, min, sec), DegToRad(deg), DegToRad(deg, min, sec),
RadToDeg(rad), Ceil(x), Floor(x), Sqrt(x), Sinh(x), Cosh(x),
Tanh(x) /Tgh(x)/, Coth(x) /Ctgh(x)/
* changed: class Objects in ttmathobjects.h has been completely rewritten,
we can change the names of user-defined variables or functions, and the
names are case-sensitive now
* added: class History which is used in functions which take a lot of time
during calculating e.g. Factorial(x)
* added: Tg(x) a wrapper for Tan(x)
* changed: CTan(x) is Cot(x) now
* added: Ctg(x) a wrapper for Cot(x)
* added: ATg(x) a wrapper for ATan(x)
* changed: ACTan(x) is ACot(x) now
* added: ACtg(x) a wrapper for ACot(x)
* added: UInt::PrintTable() (for debugging etc.)
* changed: the methods Big::SetPi() Big::SetE() and Big::SetLn2() have
been rewritten, now they have 128 32bit words (it's about 1232 valid
decimal digits)
* fixed: previous values from Big::SetPi() Big::SetE() and
Big::SetLn2() were not too much accurate (last 2-3 words were wrong)
* added: Big::SetLn10() (128 32bit words as well)
* added: macro: TTMATH_BUILTIN_VARIABLES_SIZE which is equal 128u on
32bit platforms and 64ul on 64bit platforms (128/2=64)
* added: macros: TTMATH_PLATFORM32 and TTMATH_PLATFORM64
* changed: a small optimisation in UInt::Mul2Big()
* added: at the end of ttmath.h: #include "ttmathparser.h"
this is for convenience for a programmer, he can only use #include
with ttmath.h even if he uses the parser
* added: to samples: big.cpp, parser.cpp
* added/changes/fixed: in copy-constructors and operators= in Int,
Uint and Big (more info in the commit log)
* renamed Big::SetDotOne() into Big::Set05()
* changes: a few small optimisations in Big
* deleted: the word 'virtual' from destructors: UInt, Int, Big
(types in this library are not projected to be base-classes for
another ones derived from them)
* and more small changes (look at the commit log)
* added: into the parser: SetFactorialMax()
* added: DegToDeg(deg, min, sec), DegToRad(deg), DegToRad(deg, min, sec),
RadToDeg(rad), Ceil(x), Floor(x), Sqrt(x), Sinh(x), Cosh(x),
Tanh(x) /Tgh(x)/, Coth(x) /Ctgh(x)/
* changed: class Objects in ttmathobjects.h has been completely rewritten,
we can change the names of user-defined variables or functions,
and the names are case-sensitive now
* added: class History which is used in functions which take a lot of time
during calculating e.g. Factorial(x)
* added: Tg(x) a wrapper for Tan(x)
* changed: CTan(x) is Cot(x) now
* added: Ctg(x) a wrapper for Cot(x)
* added: ATg(x) a wrapper for ATan(x)
* changed: ACTan(x) is ACot(x) now
* added: ACtg(x) a wrapper for ACot(x)
* added: UInt::PrintTable() (for debugging etc.)
* changed: the methods Big::SetPi() Big::SetE() and Big::SetLn2() have
been rewritten, now they have 128 32bit words (it's about
1232 valid decimal digits)
* fixed: previous values from Big::SetPi() Big::SetE() and
Big::SetLn2() were not too much accurate (last 2-3 words were wrong)
* added: Big::SetLn10() (128 32bit words as well)
* added: macro TTMATH_BUILTIN_VARIABLES_SIZE which is equal 128u on
32bit platforms and 64ul on 64bit platforms (128/2=64)
* added: macros TTMATH_PLATFORM32 and TTMATH_PLATFORM64
* changed: a small optimisation in UInt::Mul2Big()
* added: at the end of ttmath.h: #include "ttmathparser.h"
this is for convenience for a programmer, he can only use #include
with ttmath.h even if he uses the parser
* added: to samples: big.cpp, parser.cpp
* added/changes/fixed: in copy-constructors and operators= in Int,
Uint and Big (more info in the commit log)
* renamed: Big::SetDotOne() into Big::Set05()
* changes: a few small optimisations in Big
* deleted: the word 'virtual' from destructors: UInt, Int, Big
(types in this library are not projected to be base-classes for
another ones derived from them)
* and more small changes (look at the commit log)
Version 0.7.2 (2007.03.09):
* added: Big::Mod - the remainder from a division
* added: Big::Sgn - the 'sign' from the value (-1,0,1)
* added: global functions Mod and Sgn too
* added: checking whether a user gives a correct value of a variable or function
(user-defined variables/functions in the mathematical parser)
* added: into the parser: logical operators: > < >= <= == != && ||
* added: into the parser: logical functions: and() or() not() if()
* added: ErrorCode::err_unknown_operator when the parser couldn't read an operator
* added: Big::Mod - the remainder from a division
* added: Big::Sgn - the 'sign' from the value (-1,0,1)
* added: global functions Mod and Sgn too
* added: checking whether a user gives a correct value of a variable or function
(user-defined variables/functions in the mathematical parser)
* added: into the parser: logical operators: > < >= <= == != && ||
* added: into the parser: logical functions: and() or() not() if()
* added: ErrorCode::err_unknown_operator when the parser couldn't read an operator
Version 0.7.1 (2007.02.27):
* fixed the error 'overflow during printing' which was caused
by Big::FromInt(Int<int_size> value) (the sign has to be set at the end)
* fixed many small errors
* added ATan (arctan), ACTan (arc ctan) functions
* fixed: the error 'overflow during printing' which was caused
by Big::FromInt(Int<int_size> value) (the sign has to be set at the end)
* fixed: many small errors
* added: ATan (arctan), ACTan (arc ctan) functions
Version 0.7.0 (2007.02.24):
* finished support for 64bit platforms
* added ASin (arcsin), ACos (arccos) functions
* finished: support for 64bit platforms
* added: ASin (arcsin), ACos (arccos) functions
Version 0.6.4 (2007.01.29):
* fixed the problem with a sign in the mathematical parser /-(1) was 1/
* added UInt::AddInt and UInt::SubInt
* changed UInt::AddOne and UInt::SubOne (much faster now)
* added UInt::SetBitInWord
* changed UInt::SetBit (much faster now)
* UInt::AddTwoUints renamed to UInt::AddTwoInts
* UInt::FindLeadingBit32 renamed to UInt::FindLeadingBitInWord
* added UInt::SetBitInWord
* UInt::Mul64 renamed to UInt::MulTwoWords
* UInt::Div64 renamed to UInt::DivTwoWords
* and more small changes in UInt type
* start adding support for Amd64 (not finished yet) (added ttmathuint64.h)
* fixed: the problem with a sign in the mathematical parser /-(1) was 1/
* added: UInt::AddInt and UInt::SubInt
* changed: UInt::AddOne and UInt::SubOne (much faster now)
* added: UInt::SetBitInWord
* changed: UInt::SetBit (much faster now)
UInt::AddTwoUints renamed to UInt::AddTwoInts
UInt::FindLeadingBit32 renamed to UInt::FindLeadingBitInWord
UInt::Mul64 renamed to UInt::MulTwoWords
UInt::Div64 renamed to UInt::DivTwoWords
* added: UInt::SetBitInWord
* and more small changes in UInt type
* start adding support for Amd64 (not finished yet) (added ttmathuint64.h)
Version 0.6.3 (2007.01.22):
* position of arguments (x and base) in logarithm functions are swapped
* it's possible to use any multiplication algorithms in the same time
(macros UINT_MUL_VERSION_'X' have gone)
* added ExceptionInfo, ReferenceError and RuntimeError classes
* the mess in macros has been cleaned up
* added TTMATH_RELEASE macro
* changed: position of arguments (x and base) in logarithm functions are swapped
* changed: it's possible to use any multiplication algorithms in the same time
(macros UINT_MUL_VERSION_'X' have gone)
* added: ExceptionInfo, ReferenceError and RuntimeError classes
* changed: the mess in macros has been cleaned up
* added: TTMATH_RELEASE macro
Version 0.6.2 (2007.01.10):
* New division algorithm (radix b) where b is 2^32
* added: New division algorithm (radix b) where b is 2^32

View File

@ -1,4 +1,4 @@
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

18
README
View File

@ -7,18 +7,20 @@ subtracting, multiplying, dividing etc. With the library also goes
a mathematical parser which helps you solving input formulas read directly
from a user.
TTMath is developed under the (new) BSD licence which means that it is free
for both personal and commercial use but the library has some technical
limitations: you can use it only on i386 and Amd64, another platforms are
not supported (Intel 64bit platforms were not tested but should work as
well), and you can use this library only with the C++ programming language.
TTMath is developed under the BSD licence which means that it is free
for both personal and commercial use.
The library has some technical limitations:
* there are only two platforms that are supported: x86 and x86_64,
* you can use this library only with the C++ programming language.
The main goal of the library is to allow one to use big values in the same
way as the standard types like int, float, etc. It does not need to be
compiled first because the whole library is written as the C++ templates.
This means only C++ developers can use this library and one thing they have
to do is to use 'include' directive of the preprocessor. How big the
to do is to use 'include' directive of the preprocessor. How big the
values can be is set directly in the source code by the programmer.
Author: Tomasz Sowa <t.sowa AnTispam slimaczek.pl>
Project page: http://sourceforge.net/projects/ttmath
Author: Tomasz Sowa <t.sowa@slimaczek.pl>
Project pages: http://ttmath.slimaczek.pl
http://sourceforge.net/projects/ttmath

View File

@ -31,7 +31,7 @@ PROJECT_NAME = TTMath
# This could be handy for archiving the generated documentation or
# if some version control system is used.
PROJECT_NUMBER = 0.8.0
PROJECT_NUMBER = 0.8.2
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.

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