@@ -7,17 +7,29 @@ The main features:
77* speed: use intrinsics if supported
88* cross-platform: supports MSVC, GCC and CLANG C++17 compilers
99
10- Library implements two main classes:
10+ The library implements two main classes:
1111``` c++
12+ namespace slim
13+ {
1214template<typename native_t = uintmax_t, uint_t size = 2 >
1315class long_uint_t ; // unsigned integer
1416template<typename native_t = uintmax_t, uint_t size = 2 >
1517class long_int_t ; // signed integer
18+
19+ } // namespace slim
1620```
1721where native_t may be one of base unsigned type and size must by power of two.
22+ ## Implementation
23+ [ long_int.h] ( include/long_int.h ) - long signed integer class
24+ [ long_uint.h] ( include/long_uint.h ) - long unsigned integer class
25+ [ long_math.h] ( include/long_math.h ) - crossplatform helper classes and functions
26+ [ long_math_gcc.h] ( include/long_math_gcc.h ) - GCC, CLANG helper classes and functions
27+ [ long_math_gcc.h] ( include/long_math_msvc.h ) - MSVC helper classes and functions
1828## Integration
19- Library implements four predefined types: uint128_t, uint256_t, int128_t, int256_t. You can use them in you project by include code below:
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:
2030``` c++
31+ #include < slimcpplib/long_uint.h>
32+ // or
2133#include < slimcpplib/long_int.h>
2234
2335namespace your_namespace
@@ -32,29 +44,36 @@ namespace your_namespace
3244```
3345## Constant declaration:
3446``` c++
35- constexpr auto uo = 03766713523035452062041773345651416625031020_ui128; // octal unsigned integer
36- constexpr auto ud = 338770000845734292534325025077361652240_ui128; // decimal unsigned integer
37- constexpr auto uh = 0xfedcba9876543210fedcba9876543210_ui128; // hexadecimal unsigned integer
47+ constexpr auto uo = 03766713523035452062041773345651416625031020_ui128; // octal unsigned integer
48+ constexpr auto ud = 338770000845734292534325025077361652240_ui128; // decimal unsigned integer
49+ constexpr auto uh = 0xfedcba9876543210fedcba9876543210_ui128; // hexadecimal unsigned integer
3850
39- constexpr auto io = -03766713523035452062041773345651416625031020_si128; // octal signed integer
40- constexpr auto id = -338770000845734292534325025077361652240_si128; // decimal signed integer
41- constexpr auto ih = -0xfedcba9876543210fedcba9876543210_si128; // hexadecimal signed integer
51+ constexpr auto io = -03766713523035452062041773345651416625031020_si128; // octal signed integer
52+ constexpr auto id = -338770000845734292534325025077361652240_si128; // decimal signed integer
53+ constexpr auto ih = -0xfedcba9876543210fedcba9876543210_si128; // hexadecimal signed integer
4254```
4355also supported (') separator for integer literals:
4456``` c++
45- constexpr auto u = 0xfedcba98'76543210'fedcba98' 76543210_ui128; // hexadecimal unsigned integer
57+ constexpr auto u = 0xfedcba98'76543210'fedcba98' 76543210_ui128; // hexadecimal unsigned integer
4658```
4759## Construction:
4860``` c++
49- const uint128_t u; // construct uninitialized unsigned integer
50- const uint128_t u = 1U ; // construction from unsigned integer
51- const int128_t s = -1 ; // construction from signed integer
52- const uint128_t u = 10000_ui128; // construction from long unsigned integer
53- const int128_t u = -10000_i128; // construction from long signed integer
54- const uint128_t u = true ; // construction from boolean value
61+ const uint128_t u; // construct uninitialized unsigned integer
62+ const uint128_t u = 1U ; // construction from unsigned integer
63+ const int128_t s = -1 ; // construction from signed integer
64+ const uint128_t u = 10000_ui128; // construction from long unsigned integer
65+ const int128_t u = -10000_i128; // construction from long signed integer
66+ const uint128_t u = true ; // construction from boolean value
5567```
5668## Operators
5769long_uint_t type supports following operators:
58- ==, !=, <, <=, >, >=, <<=, <<, >>=, >>, +=, +, ++, -=, -, --, * =, * , /=, /, %=, %, ~ , &=, &, |=, |, ^=, ^
70+ ` ==, !=, <, <=, >, >=, <<=, <<, >>=, >>, +=, +, ++, -=, -, --, *=, *, /=, /, %=, %, ~, &=, &, |=, |, ^=, ^`
5971long_int_t type supports following operators:
60- ==, !=, <, <=, >, >=, <<=, <<, >>=, >>, +=, +, ++, -=, -, --, * =, * , /=, /, %=, %
72+ ` ==, !=, <, <=, >, >=, <<=, <<, >>=, >>, +=, +, ++, -=, -, --, *=, *, /=, /, %=, % `
73+ ## MulDiv
74+ 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.
75+ ``` c++
76+ template <typename type_t >
77+ constexpr type_t muldiv (const type_t& value, const type_t& multiplier, const type_t& divider) noexcept;
78+ ```
79+ ## Restrictions
0 commit comments