## What is TTMath?

TTMath is a big numbers library for C++ programming language. It performs mathematical operations with unsigned/signed integers and floating point numbers.

## How big the values can be?

All the values in TTMath are stored on the stack. This library doesn't use the heap (malloc/new etc.) because the cost of allocating memory on it is too high. (We're often creating and destroying small objects). On the other hand we must note that the stack usually isn't too large, normally today's operating systems offer about 2Mb for the stack. This library was projected with the intention of using values with about 100 32bit words max. But it can be used with more than 100 words if your operating system allows the stack to be greater.

## What does 100 words in a value mean?

For example if we used ttmath:UInt<100> type on the 32bit platform the value in this type would be from 0 to 2^(32*100)-1 and it's about 1,977e+963.

## What are floating point numbers?

Floating point numbers consist of a mantissa and an exponent. The value from a floating point object is calculated as mantissa * base^exponent. On binary computers the base is usually equal 2. There is not too much place here to explain more about floating point numbers but one thing worth noticing about it is that floating point numbers are usually not very 'strict'. For example, value 5 can be perfectly expressed as the floating point number but value 5.1 cannot be when the base is equal 2. The value is actually an approximation of the 5.1. In binary format it's 101.0(0011) and the part (0011) will be repeated again and again. I assume that you have a little knowledge about the floating point numbers.

## Where cannot I use the floating point numbers?

As the value is often only an approximation of the real value you cannot use it for example when you're calculating money.

## How floating point numbers are stored in this library?

The basic type in the library is ttmath::UInt<n>. It implements an integer value without a sign. As the parameter n you specify how many words (machine-words) the type will be held. For example when you create an object ttmath::UInt<3> on 32bit platform it means that this object can hold a value from 0 to 2^(32*3)-1. The next type is ttmath::Int<n>. This type expresses a signed integer value, it is derived from UInt. And the last type is ttmath::Big<e,m>. This type manages the floating point values, it has a mantissa of type ttmath::UInt<m> and an exponent ttmath::Int<e>.

## Which mathematical operations are performed?

Only basic operations like adding, subtracting, multiplying, dividing, powering, the logarithm and the exponent, trigonometric functions and functions reverse to them, hyperbolic functions and inverse hyperbolic functions.

## Which algorithms are used?

For the list of used algorithms look into the documentation (will be soon). These algorithms are very basic algorithms, they work well if we're using the size of values up to 15 words max. I don't plan to implement another special algorithms then if you care about the speed you should consider to use the Gnu GMP Bignum Library which has special algorithms for very big values.

## Which hardware platforms are supported?

At the moment Intel i386 and Amd64 are supported. Intel 64bit platforms should be working too but I don't have such platform to make tests on it.

## Why there are only two platforms on which this library can run on?

Some parts of the library are written in the assembler language. In means that if you want to make this library available on another platform that part of code must be rewritten. I don't have enough time and special knowledge about another assemblers.

## What about an operating system?

It doesn't matter which operating system you're using.

## Can I use this library with another language than C++?

No, this library is written as the C++ templates. That means only C++ users can use it.

## Must I compile it beforehand?

No, since the library is written as the C++ templates you don't have to compile it.

## How can I install it?

Just copy these files somewhere in your file system. For example into /usr/local/include/ttmath. Then, only what you have to do is to use the #include command of the preprocessor.

## Which compiler can I use?

At the moment only two compilers are supported: GCC from 3.4 and Microsoft Visual C++ from 7.0. Another compilers were not tested. But if you're using this library on 64bit platforms you can only use GCC (Microsoft doesn't provide the inline assembler in its 64bit compiler).

## Were there any problems with the assembler code with these two compilers?

Yes, there were. GCC has its own assembler syntax different from Microsoft Visual C++. This is why I was making two parts of the assembler code: one for Visual (and other compilers) and second for GCC.

## Which of these two assemblers is better?

As the GCC assembler has the extended syntax you can simply tell which registers are used, which will hold the values and which will be changed. This means that you don't have to use for example Push and Pop instructions if you're changing some registers, so the assembler for GCC is better optimised.

## The assembler was really needed?

Yes, some kind of operations is better doing when we're using the assembler. For example if you want to add two integers together and make a test whether there was a carry or not only what you have to do in the assembler is to test the carry-flag in a special register. In such languages as C++ you cannot do it as simply as in the assembler.

## Does this library use another libraries?

TTMath library uses only Standard C++ Library which goes with your compiler. Another libraries like Boost etc were not used.

## Where is a documentation?

I think the documentation should be ready in 2 month's time. If you have any questions feel free to ask on our forum: http://www.ttmath.org/forum

## Is the current version of this library ready to use?

Yes, version 0.7.2 is stable and seems to work correctly. But I plan to change somewhat in the interface before the version 1.0 will be available.

## When will be the 1.0 version of this library?

It's a lot work to do yet. Especially the documentation, samples, and tests. I suppose the 1.0 version will not be sooner than in 6 month's time.

## Are there any projects which use the TTMath library?

I wrote a simple calculator for Microsoft Windows operating systems. You can download it from http://sourceforge.net/projects/ttcalc