Skip to the content.

Big Integers

Headers



Namespace



Initializing from an integral type.

apa::bint num1 = 255;
apa::bint num2 = -128;
// base 10 equivalent = 255 and -128


Initializing from a base2 (binary) number represented by a string.

Binary formatter 0b

apa::bint num1 = "0b11001001110100111110100010101";
apa::bint num2 = "-0b11001001110100111110100010101";
// base 10 equivalent = 423263509 and -423263509


Initializing from a base8 (octal) number represented by a string.

Octal formatter 0o

apa::bint num1 = "0o122333444455555666666777777700000000";
apa::bint num2 = "-0o122333444455555666666777777700000000";
// base 10 equivalent
// num1 =  52245490915446306574707453853696
// num2 = -52245490915446306574707453853696


Initializing from a base10 (decimal) number represented by a string.

Decimal numbers don’t need a formatter.

apa::bint num1 = "1192098127666217730001983712379812737234";
apa::bint num2 = "-1192098127666217730001983712379812737234";
// base10 equivalent
// num1 =  1192098127666217730001983712379812737234
// num2 = -1192098127666217730001983712379812737234


Initializing from a base16 (hex) number represented by a string.

Hex formatter 0x

apa::bint num1 = "0xdeed0feed0dead0beef0fac0bae";
apa::bint num2 = "-0xdeed0feed0dead0beef0fac0bae";
// base10 equivalent
// num1 =  282592308594525234095480996891566
// num2 = -282592308594525234095480996891566


Initializing with specific limb values.

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



Supported Operators of apa::bint.

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)


bint methods.



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.

apa namespace functions.


Go Back to Docs