-
Header Mode :
include "APA/core.hpp"
-
Static Lib :
include <APA/bint.hpp>
apa::bint
apa::bint num1 = 255;
apa::bint num2 = -128;
// base 10 equivalent = 255 and -128
Binary formatter 0b
apa::bint num1 = "0b11001001110100111110100010101";
apa::bint num2 = "-0b11001001110100111110100010101";
// base 10 equivalent = 423263509 and -423263509
Octal formatter 0o
apa::bint num1 = "0o122333444455555666666777777700000000";
apa::bint num2 = "-0o122333444455555666666777777700000000";
// base 10 equivalent
// num1 = 52245490915446306574707453853696
// num2 = -52245490915446306574707453853696
Decimal numbers don't need a formatter.
apa::bint num1 = "1192098127666217730001983712379812737234";
apa::bint num2 = "-1192098127666217730001983712379812737234";
// base10 equivalent
// num1 = 1192098127666217730001983712379812737234
// num2 = -1192098127666217730001983712379812737234
Hex formatter 0x
apa::bint num1 = "0xdeed0feed0dead0beef0fac0bae";
apa::bint num2 = "-0xdeed0feed0dead0beef0fac0bae";
// base10 equivalent
// num1 = 282592308594525234095480996891566
// num2 = -282592308594525234095480996891566
apa::bint positive_num({ 0xfeed, 0xdead, 0xbeef },apa::POSITIVE);
apa::bint negative_num({ 0xfeed, 0xdead, 0xbeef },apa::NEGATIVE);
The values 0xfeed
, 0xdead
and 0xbeef
values will be
assigned to each limb of the bint
instance.
Each element in the initializer list can only hold a max value of the base size (depending on the base size you choose during compilation).
- Base 216 max value =
0xffff
- Base 232 max value =
0xffffffff
- Base 264 max value =
0xffffffffffffffff
Labels | Operators |
---|---|
Negation | - |
Arithmetic | + , - , * , / , % , += , -= , *= , /= , %= |
Increment | ++ (Post-Fix and Pre-Fix) |
Decrement | -- (Post-Fix and Pre-Fix) |
Relational | < , > , == , <= , >= , != |
Logical | ! , && , || |
Bitwise Logical | ~ , & , ^ , |= , &= , ^= |
Bitwise Shifts (for size_t only) |
<< , >> , <<= , >>= |
Standard I/O (std cin and cout) | << , >> (only accepts and output hex format) |
.printHex()
- prints the value ofbint
in hex format.to_base10_string()
- returns a string that represents the value ofbint
in base 10 (decimal).to_base16_string()
- returns a string that represents the value ofbint
in base 16 (hex).capacity_size()
- returns the total allocated number of limbs of abint
variable.limb_size()
- returns the number of limbs currently used by abint
variable.byte_size()
- returns the total number of bytes.bit_size()
- returns the total number of bits.limb_view()
- returns aconst *limb_t
pointer array.byte_view()
- returns aconst *uint8_t
pointer array.detach()
- returns a pointer that points to thelimbs
array ofbint
instance, while setting thelimbs
of thebint
instance toNULL
Available using the header:
// for static library users only.
#include <APA/math.hpp>
If you are not using the static library and just compiling
directly using the core header file: #include "APA/core.hpp"
,
there is no need to include the math.hpp
header.
swap(bint& a, bint& b)
- swap values of twobint
class.factorial(size_t n)
- returnsbint
factorialfibonacci(size_t nth)
- returnsbint
Fibonaccipower(const bint& base, const bint& exponent)
- returnsbint
power