![]() |
TTMath
0.9.4
C++ bignum library
|
constants used in the library More...
#include <stdexcept>
#include <sstream>
#include <vector>
#include <stdint.h>
Go to the source code of this file.
Data Structures | |
struct | ttmath::Conv |
class | ttmath::StopCalculating |
class | ttmath::ExceptionInfo |
class | ttmath::ReferenceError |
class | ttmath::RuntimeError |
Namespaces | |
ttmath | |
a namespace for the TTMath library | |
Macros | |
#define | TTMATH_MAJOR_VER 0 |
#define | TTMATH_MINOR_VER 9 |
#define | TTMATH_REVISION_VER 4 |
#define | TTMATH_PRERELEASE_VER 1 |
#define | TTMATH_NOASM |
#define | TTMATH_NOASM |
#define | TTMATH_BITS_PER_UINT 64ul |
#define | TTMATH_UINT_HIGHEST_BIT 9223372036854775808ul |
#define | TTMATH_UINT_MAX_VALUE 18446744073709551615ul |
#define | TTMATH_BUILTIN_VARIABLES_SIZE 128ul |
#define | TTMATH_BITS(min_bits) ((min_bits-1)/64 + 1) |
#define | TTMATH_ARITHMETIC_MAX_LOOP 10000 |
#define | TTMATH_USE_KARATSUBA_MULTIPLICATION_FROM_SIZE 5 |
#define | TTMATH_GAMMA_BOUNDARY 2000 |
#define | TTMATH_REFERENCE_ASSERT(expression) |
#define | TTMATH_ASSERT(expression) |
#define | TTMATH_LOG(msg) |
#define | TTMATH_LOGC(msg, carry) |
#define | TTMATH_VECTOR_LOG(msg, vector, len) |
#define | TTMATH_VECTOR_LOGC(msg, carry, vector, len) |
Typedefs | |
typedef unsigned long | ttmath::uint |
typedef signed long | ttmath::sint |
Enumerations | |
enum | ttmath::LibTypeCode { asm_vc_32 = 0, asm_gcc_32, asm_vc_64, asm_gcc_64, no_asm_32, no_asm_64 } |
enum | ttmath::ErrorCode { err_ok = 0, err_nothing_has_read, err_unknown_character, err_unexpected_final_bracket, err_stack_not_clear, err_unknown_variable, err_division_by_zero, err_interrupt, err_overflow, err_unknown_function, err_unknown_operator, err_unexpected_semicolon_operator, err_improper_amount_of_arguments, err_improper_argument, err_unexpected_end, err_internal_error, err_incorrect_name, err_incorrect_value, err_variable_exists, err_variable_loop, err_functions_loop, err_must_be_only_one_value, err_object_exists, err_unknown_object, err_still_calculating, err_in_short_form_used_function, err_percent_from } |
constants used in the library
As our library is written in header files (templates) we cannot use constants like 'const int' etc. because we should have some source files .cpp to define this variables. Only what we can have are constants defined by #define preprocessor macros.
All macros are preceded by TTMATH_ prefix
Definition in file ttmathtypes.h.
#define TTMATH_ARITHMETIC_MAX_LOOP 10000 |
this variable defines how many iterations are performed during some kind of calculating when we're making any long formulas (for example Taylor series)
it's used in ExpSurrounding0(...), LnSurrounding1(...), Sin0pi05(...), etc.
note! there'll not be so many iterations, iterations are stopped when there is no sense to continue calculating (for example when the result still remains unchanged after adding next series and we know that the next series are smaller than previous ones)
Definition at line 310 of file ttmathtypes.h.
Referenced by ttmath::Big< exp, man >::Exp(), and ttmath::Big< exp, man >::Sqrt().
#define TTMATH_BITS | ( | min_bits | ) | ((min_bits-1)/64 + 1) |
this macro returns the number of machine words capable to hold min_bits bits e.g. TTMATH_BITS(128) returns 2
Definition at line 278 of file ttmathtypes.h.
#define TTMATH_BITS_PER_UINT 64ul |
on 64bit platforms we do not define ulint and slint
how many bits there are in the uint type
Definition at line 253 of file ttmathtypes.h.
Referenced by ttmath::Big< exp, man >::Big(), ttmath::Big< exp, man >::BitAnd(), ttmath::UInt< man >::BitNot2(), ttmath::Big< exp, man >::BitOr(), ttmath::Big< exp, man >::BitXor(), ttmath::UInt< man >::ClearFirstBits(), ttmath::UInt< man >::CompensationToLeft(), ttmath::UInt< man >::Div1(), ttmath::Big< exp, man >::Exp(), ttmath::Big< exp, man >::FromBig(), ttmath::Big< exp, man >::FromDouble(), ttmath::Big< exp, man >::FromInt(), ttmath::Big< exp, man >::FromUInt(), ttmath::Big< exp, man >::IsInteger(), ttmath::Big< exp, man >::Ln(), ttmath::Big< exp, man >::Mod2(), ttmath::UInt< man >::MulBig(), ttmath::Big< exp, man >::MulUInt(), ttmath::Big< exp, man >::Pow(), ttmath::UInt< man >::Rcl(), ttmath::UInt< man >::Rcr(), ttmath::Big< exp, man >::Set05Pi(), ttmath::Big< exp, man >::Set2Pi(), ttmath::Big< exp, man >::SetE(), ttmath::Big< exp, man >::SetLn10(), ttmath::Big< exp, man >::SetLn2(), ttmath::Big< exp, man >::SetOne(), ttmath::Big< exp, man >::SetPi(), ttmath::UInt< man >::SubOne(), ttmath::Big< exp, man >::ToDouble(), ttmath::Int< exp >::ToInt(), ttmath::Big< exp, man >::ToInt(), ttmath::UInt< man >::ToInt(), ttmath::UInt< man >::ToStringBase(), and ttmath::UInt< man >::UInt().
#define TTMATH_BUILTIN_VARIABLES_SIZE 128ul |
the number of words (64bit words on 64bit platforms) which are kept in built-in variables for a Big<> type (these variables are defined in ttmathbig.h)
Definition at line 271 of file ttmathtypes.h.
#define TTMATH_GAMMA_BOUNDARY 2000 |
this is a special value used when calculating the Gamma(x) function if x is greater than this value then the Gamma(x) will be calculated using some kind of series
don't use smaller values than about 100
Definition at line 338 of file ttmathtypes.h.
Referenced by ttmath::CGamma< ValueType >::InitAll().
#define TTMATH_MAJOR_VER 0 |
the major version of the library
the version present to the end user is constructed in this way:
TTMATH_MAJOR_VER.TTMATH_MINOR_VER.TTMATH_REVISION_VER.[prerelease if TTMATH_PRERELEASE_VER==1]
Definition at line 73 of file ttmathtypes.h.
#define TTMATH_MINOR_VER 9 |
the minor version of the library
the version present to the end user is constructed in this way:
TTMATH_MAJOR_VER.TTMATH_MINOR_VER.TTMATH_REVISION_VER.[prerelease if TTMATH_PRERELEASE_VER==1]
Definition at line 82 of file ttmathtypes.h.
#define TTMATH_NOASM |
you can define a platform explicitly by defining either TTMATH_PLATFORM32 or TTMATH_PLATFORM64 macro
asm version of the library is available by default only for: x86 and amd64 platforms and for Microsoft Visual and GCC compilers
but you can force using asm version (the same asm as for Microsoft Visual) by defining TTMATH_FORCEASM macro you have to be sure that your compiler accept such an asm format
x86 architecture: i386 defined by GNU C X86 defined by MinGW32 _M_IX86 defined by Visual Studio, Intel C/C++, Digital Mars and Watcom C/C++
amd64 architecture: x86_64 defined by GNU C, CLANG (LLVM) and Sun Studio _M_X64 defined by Visual Studio
asm version is available only for x86 or amd64 platforms
another compilers than MS VC or GCC or CLANG (LLVM) by default use no asm version (CLANG defines GNUC too)
Definition at line 165 of file ttmathtypes.h.
#define TTMATH_NOASM |
you can define a platform explicitly by defining either TTMATH_PLATFORM32 or TTMATH_PLATFORM64 macro
asm version of the library is available by default only for: x86 and amd64 platforms and for Microsoft Visual and GCC compilers
but you can force using asm version (the same asm as for Microsoft Visual) by defining TTMATH_FORCEASM macro you have to be sure that your compiler accept such an asm format
x86 architecture: i386 defined by GNU C X86 defined by MinGW32 _M_IX86 defined by Visual Studio, Intel C/C++, Digital Mars and Watcom C/C++
amd64 architecture: x86_64 defined by GNU C, CLANG (LLVM) and Sun Studio _M_X64 defined by Visual Studio
asm version is available only for x86 or amd64 platforms
another compilers than MS VC or GCC or CLANG (LLVM) by default use no asm version (CLANG defines GNUC too)
Definition at line 165 of file ttmathtypes.h.
#define TTMATH_PRERELEASE_VER 1 |
TTMATH_PRERELEASE_VER is either zero or one zero means that this is the release version of the library (one means something like beta)
the version present to the end user is constructed in this way:
TTMATH_MAJOR_VER.TTMATH_MINOR_VER.TTMATH_REVISION_VER.[prerelease if TTMATH_PRERELEASE_VER==1]
Definition at line 102 of file ttmathtypes.h.
#define TTMATH_REFERENCE_ASSERT | ( | expression | ) |
TTMATH_DEBUG this macro enables further testing during writing your code you don't have to define it in a release mode
if this macro is set then macros TTMATH_ASSERT and TTMATH_REFERENCE_ASSERT are set as well and these macros can throw an exception if a condition in it is not fulfilled (look at the definition of TTMATH_ASSERT and TTMATH_REFERENCE_ASSERT)
TTMATH_DEBUG is set automatically if DEBUG or _DEBUG are defined
Definition at line 681 of file ttmathtypes.h.
Referenced by ttmath::Big< exp, man >::Div(), ttmath::UInt< man >::Div1(), ttmath::Big< exp, man >::Mul(), ttmath::UInt< man >::MulBig(), and ttmath::Big< exp, man >::Sqrt().
#define TTMATH_REVISION_VER 4 |
the revision version of the library
the version present to the end user is constructed in this way:
TTMATH_MAJOR_VER.TTMATH_MINOR_VER.TTMATH_REVISION_VER.[prerelease if TTMATH_PRERELEASE_VER==1]
Definition at line 91 of file ttmathtypes.h.
#define TTMATH_UINT_HIGHEST_BIT 9223372036854775808ul |
the mask for the highest bit in the unsigned 64bit word (2^63)
Definition at line 258 of file ttmathtypes.h.
Referenced by ttmath::Big< exp, man >::Exp(), ttmath::Int< exp >::FromUInt(), ttmath::Int< exp >::Int(), ttmath::UInt< man >::IsOnlyTheHighestBitSet(), ttmath::UInt< man >::IsTheHighestBitSet(), ttmath::Big< exp, man >::Mul(), ttmath::Int< exp >::Pow(), ttmath::UInt< man >::SetFromTable(), ttmath::Int< exp >::SetMax(), ttmath::Int< exp >::SetMin(), ttmath::Big< exp, man >::SetOne(), ttmath::UInt< man >::Sqrt(), ttmath::UInt< man >::Swap(), ttmath::Int< exp >::ToInt(), ttmath::Big< exp, man >::ToInt(), ttmath::UInt< man >::ToInt(), and ttmath::Int< exp >::ToUInt().
#define TTMATH_UINT_MAX_VALUE 18446744073709551615ul |
the max value of the unsigned 64bit word (2^64 - 1) (all bits equal one)
Definition at line 264 of file ttmathtypes.h.
Referenced by ttmath::UInt< man >::BitNot2(), ttmath::Int< exp >::FromInt(), ttmath::Int< exp >::Int(), ttmath::Big< exp, man >::IsInteger(), ttmath::Int< exp >::Pow(), ttmath::UInt< man >::SetFromTable(), ttmath::UInt< man >::SetMax(), ttmath::UInt< man >::SubOne(), ttmath::UInt< man >::Swap(), ttmath::Int< exp >::ToInt(), and ttmath::Big< exp, man >::ToInt().
#define TTMATH_USE_KARATSUBA_MULTIPLICATION_FROM_SIZE 5 |
this is a limit when calculating Karatsuba multiplication if the size of a vector is smaller than TTMATH_USE_KARATSUBA_MULTIPLICATION_FROM_SIZE the Karatsuba algorithm will use standard schoolbook multiplication
Definition at line 326 of file ttmathtypes.h.
Referenced by ttmath::UInt< man >::MulFastestBig().