All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Namespaces | Macros | Typedefs | Enumerations
ttmathtypes.h File Reference

constants used in the library More...

#include <stdexcept>
#include <sstream>
#include <vector>
#include <stdint.h>

Go to the source code of this file.

Classes

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   3
 
#define TTMATH_PRERELEASE_VER   0
 
#define TTMATH_PLATFORM32
 
#define TTMATH_NOASM
 
#define TTMATH_NOASM
 
#define TTMATH_BITS_PER_UINT   32u
 
#define TTMATH_UINT_HIGHEST_BIT   2147483648u
 
#define TTMATH_UINT_MAX_VALUE   4294967295u
 
#define TTMATH_BUILTIN_VARIABLES_SIZE   256u
 
#define TTMATH_BITS(min_bits)   ((min_bits-1)/32 + 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 int ttmath::uint
 
typedef signed int ttmath::sint
 
typedef uint64_t ttmath::ulint
 
typedef int64_t ttmath::slint
 

Enumerations

enum  ttmath::LibTypeCode {
  ttmath::asm_vc_32 = 0, ttmath::asm_gcc_32, ttmath::asm_vc_64, ttmath::asm_gcc_64,
  ttmath::no_asm_32, ttmath::no_asm_64
}
 
enum  ttmath::ErrorCode {
  ttmath::err_ok = 0, ttmath::err_nothing_has_read, ttmath::err_unknown_character, ttmath::err_unexpected_final_bracket,
  ttmath::err_stack_not_clear, ttmath::err_unknown_variable, ttmath::err_division_by_zero, ttmath::err_interrupt,
  ttmath::err_overflow, ttmath::err_unknown_function, ttmath::err_unknown_operator, ttmath::err_unexpected_semicolon_operator,
  ttmath::err_improper_amount_of_arguments, ttmath::err_improper_argument, ttmath::err_unexpected_end, ttmath::err_internal_error,
  ttmath::err_incorrect_name, ttmath::err_incorrect_value, ttmath::err_variable_exists, ttmath::err_variable_loop,
  ttmath::err_functions_loop, ttmath::err_must_be_only_one_value, ttmath::err_object_exists, ttmath::err_unknown_object,
  ttmath::err_still_calculating, ttmath::err_in_short_form_used_function, ttmath::err_percent_from
}
 

Detailed Description

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

Macro Definition Documentation

#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)

#define TTMATH_ASSERT (   expression)
#define TTMATH_BITS (   min_bits)    ((min_bits-1)/32 + 1)

this macro returns the number of machine words capable to hold min_bits bits e.g. TTMATH_BITS(128) returns 4

#define TTMATH_BITS_PER_UINT   32u

how many bits there are in the uint type

#define TTMATH_BUILTIN_VARIABLES_SIZE   256u

the number of words (32bit words on 32bit platform) which are kept in built-in variables for a Big<> type (these variables are defined in ttmathbig.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

#define TTMATH_LOG (   msg)
#define TTMATH_LOGC (   msg,
  carry 
)
#define TTMATH_MAJOR_VER   0

the version of the library

TTMATH_PRERELEASE_VER is either zero or one zero means that this is the release version of the library (one means something like beta)

#define TTMATH_MINOR_VER   9
#define TTMATH_NOASM

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)

#define TTMATH_NOASM

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)

#define TTMATH_PLATFORM32

you can define a platform explicitly by defining either TTMATH_PLATFORM32 or TTMATH_PLATFORM64 macro

#define TTMATH_PRERELEASE_VER   0
#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

#define TTMATH_REVISION_VER   3
#define TTMATH_UINT_HIGHEST_BIT   2147483648u

the mask for the highest bit in the unsigned 32bit word (2^31)

#define TTMATH_UINT_MAX_VALUE   4294967295u

the max value of the unsigned 32bit word (2^32 - 1) (all bits equal one)

#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

#define TTMATH_VECTOR_LOG (   msg,
  vector,
  len 
)
#define TTMATH_VECTOR_LOGC (   msg,
  carry,
  vector,
  len 
)