|
1 | 1 | # SLIMCPP |
2 | | -# Simple long integer math libtary for C++ |
3 | | -This library implements long integers that exceed maximum size of native type supported by a specific compiler by 2-4 times. In some cases, it is necessary to temporarily perform calculations with precision exceeding the maximum supported size of integers, and then return the result to its native size again. |
| 2 | +# Simple long integer math library for C++ |
| 3 | +SLIMCPP is C++ header-only library that implements long integers that exceed maximum size of native type supported by a specific compiler by 2-4 times. All classes, methods and functions were not created or designed to work with huge numbers, for which there are specialized mathematical libraries. In some cases, it is necessary to temporarily perform calculations with precision exceeding the maximum supported size of integers, and then return the result to its native size again. The conditions are ideal for SLIMCPP. |
4 | 4 | The main features: |
5 | 5 | * easy to use: the library is header-only |
6 | 6 | * small: consists of few header files, there is no dependencies |
@@ -28,9 +28,9 @@ where native_t may be one of base unsigned type and size must by power of two. |
28 | 28 | ## Integration |
29 | 29 | The library implements four predefined types: uint128_t, uint256_t, int128_t, int256_t. You can use them in you project by include code below: |
30 | 30 | ```c++ |
31 | | -#include <slimcpplib/long_uint.h> |
| 31 | +#include <slimcpplib/long_int.h> // Include all integers support |
32 | 32 | // or |
33 | | -#include <slimcpplib/long_int.h> |
| 33 | +#include <slimcpplib/long_uint.h> // Include only unsigned integers support |
34 | 34 |
|
35 | 35 | namespace your_namespace |
36 | 36 | { |
@@ -70,11 +70,13 @@ const uint128_t u = true; // construction from boolean value |
70 | 70 | ` ==, !=, <, <=, >, >=, <<=, <<, >>=, >>, +=, +, ++, -=, -, --, *=, *, /=, /, %=, %, ~, &=, &, |=, |, ^=, ^` |
71 | 71 |
|
72 | 72 | * long_int_t type supports following operators: |
73 | | -`==, !=, <, <=, >, >=, <<=, <<, >>=, >>, +=, +, ++, -=, -, --, *=, *, /=, /, %=, %` |
| 73 | +`==, !=, <, <=, >, >=, +=, +, ++, -=, -, --, *=, *, /=, /, %=, %` |
74 | 74 | ## MulDiv |
75 | 75 | The library implements the muldiv method for faster calculation of the following expressions: (a * b / c). It can be used with signed and unsigned integers. |
76 | 76 | ```c++ |
77 | 77 | template<typename type_t> |
78 | 78 | constexpr type_t muldiv(const type_t& value, const type_t& multiplier, const type_t& divider) noexcept; |
79 | 79 | ``` |
80 | 80 | ## Limitations |
| 81 | +* Although all methods and functions are defined using the constexpr qualifier, due to the limitations of C++ 17, working completely at compile time is only possible for code without instrinsics, since there is no implementation of [std::is_constant_evaluated()](https://en.cppreference.com/w/cpp/types/is_constant_evaluated) in the standard before C++ 20. |
| 82 | +* The design of long integers tries to completely repeat the behavior of native integers, but still differs. For example, the propagation of integer types always occurs from a signed integer to an unsigned integer, and an implicit conversion from a larger integer to a smaller integer does not cause a warning, but a compilation error. |
0 commit comments