IntInit
Description
Initialize an Int (numeric value 0). Inside a Scope block the allocator argument may be omitted (MisraScope is used). Otherwise pass a typed allocator handle or a raw Allocator *.
Usage example (from documentation)
Scope(alloc, DefaultAllocator) {
Int value = IntInit();
...
}Success
Returns a numerically-zero Int whose backing bitvector is bound to the chosen allocator.
Failure
Cannot fail at construction; first allocator OOM surfaces from later math/grow.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Io.c:3379:
Str temp = StrInitFromCstr(start, StrIterIndex(&si) - StrIterIndex(&saved), IntAllocator(value));
Int parsed = IntInit(IntAllocator(value));
bool ok = IntTryFromStrRadix(&parsed, StrBegin(&temp), radix);- In
Int.c:40:
}
*out = IntInit(alloc);
if (bits == 0) {
return true;- In
Int.c:47:
if (!BitVecTryFromInteger(INT_BITS(out), value, bits, alloc)) {
IntDeinit(out);
*out = IntInit(alloc);
return false;
}- In
Int.c:148:
static SignedInt sint_init(Allocator *alloc) {
SignedInt value = {.negative = false, .magnitude = IntInit(alloc)};
return value;
}- In
Int.c:260:
Int lhs;
Int rhs;
Int result = IntInit(IntAllocator(value));
if (!int_try_clone_value(&lhs, value)) {- In
Int.c:285:
Int lhs;
Int rhs;
Int result = IntInit(IntAllocator(value));
if (!int_try_clone_value(&lhs, value)) {- In
Int.c:351:
ValidateInt(out);
result = IntInit(IntAllocator(out));
if (!int_validate_radix(radix)) {- In
Int.c:472:
ValidateInt(value);
*out = IntInit(IntAllocator(value));
if (!BitVecTryClone(INT_BITS(out), INT_BITS(value))) {
return false;- In
Int.c:489:
ValidateInt(value);
clone = IntInit(IntAllocator(value));
(void)int_try_clone_value(&clone, value);
return clone;- In
Int.c:495:
Int int_from_u64(u64 value, Allocator *alloc) {
Int result = IntInit(alloc);
(void)int_try_from_u64(&result, value, alloc);- In
Int.c:541:
}
Int result = IntInit(alloc);
if (len == 0) {- In
Int.c:596:
}
Int result = IntInit(alloc);
for (u64 i = 0; i < len; i++) {- In
Int.c:601:
if (!IntShiftLeft(&result, 8) || !int_add_u64_in_place(&result, bytes[i])) {
IntDeinit(&result);
return IntInit(alloc);
}
}- In
Int.c:676:
Int int_from_str_zstr(Zstr decimal, Allocator *alloc) {
Int out = IntInit(alloc);
(void)int_try_from_str_zstr(&out, decimal);- In
Int.c:683:
Int int_from_str_str(const Str *decimal, Allocator *alloc) {
Int out = IntInit(alloc);
(void)int_try_from_str_str(&out, decimal);- In
Int.c:734:
Int int_from_str_radix_zstr(Zstr digits, u8 radix, Allocator *alloc) {
Int out = IntInit(alloc);
(void)int_try_from_str_radix_zstr(&out, digits, radix);- In
Int.c:741:
Int int_from_str_radix_str(const Str *digits, u8 radix, Allocator *alloc) {
Int out = IntInit(alloc);
(void)int_try_from_str_radix_str(&out, digits, radix);- In
Int.c:788:
// once and reuse the quotient/remainder buffers (the quotient reserved once
// to the value's width) instead of allocating a fresh Int per digit-chunk.
Int chunk_divisor = IntInit(alloc);
Int quotient = IntInit(alloc);
Int remainder = IntInit(alloc);- In
Int.c:789:
// to the value's width) instead of allocating a fresh Int per digit-chunk.
Int chunk_divisor = IntInit(alloc);
Int quotient = IntInit(alloc);
Int remainder = IntInit(alloc);- In
Int.c:790:
Int chunk_divisor = IntInit(alloc);
Int quotient = IntInit(alloc);
Int remainder = IntInit(alloc);
if (!int_try_from_u64(&chunk_divisor, chunk, alloc) || !IntReserve("ient, IntBitLength(value))) {- In
Int.c:900:
Int int_from_binary_zstr(Zstr binary, Allocator *alloc) {
Int out = IntInit(alloc);
(void)int_try_from_binary_zstr(&out, binary);- In
Int.c:907:
Int int_from_binary_str(const Str *binary, Allocator *alloc) {
Int out = IntInit(alloc);
(void)int_try_from_binary_str(&out, binary);- In
Int.c:949:
Int int_from_oct_str_zstr(Zstr octal, Allocator *alloc) {
Int out = IntInit(alloc);
(void)int_try_from_oct_str_zstr(&out, octal);- In
Int.c:956:
Int int_from_oct_str_str(const Str *octal, Allocator *alloc) {
Int out = IntInit(alloc);
(void)int_try_from_oct_str_str(&out, octal);- In
Int.c:986:
Int int_from_hex_str_zstr(Zstr hex, Allocator *alloc) {
Int out = IntInit(alloc);
(void)int_try_from_hex_str_zstr(&out, hex);- In
Int.c:993:
Int int_from_hex_str_str(const Str *hex, Allocator *alloc) {
Int out = IntInit(alloc);
(void)int_try_from_hex_str_str(&out, hex);- In
Int.c:1432:
// read back limb-by-limb during accumulation, so it must stay independent of
// the operands: clone a/b only if they alias result.
Int a_copy = IntInit(IntAllocator(result));
Int b_copy = IntInit(IntAllocator(result));
bool ok = false;- In
Int.c:1433:
// the operands: clone a/b only if they alias result.
Int a_copy = IntInit(IntAllocator(result));
Int b_copy = IntInit(IntAllocator(result));
bool ok = false;- In
Int.c:1566:
// int_mul writing in place, scratch keeps its capacity across iterations
// instead of a fresh Init per multiply.
Int scratch = IntInit(IntAllocator(result));
while (exponent > 0) {- In
Int.c:1621:
// dividend < divisor: quotient = 0, remainder = dividend.
if (int_compare(dividend, divisor) < 0) {
Int r0 = IntInit(IntAllocator(remainder));
if (!int_try_clone_value(&r0, dividend)) {- In
Int.c:1638:
// place and set the quotient bit. The loop reads dividend and divisor while
// mutating the outputs, so any input that aliases an output is cloned first.
Int dividend_copy = IntInit(IntAllocator(quotient));
Int divisor_copy = IntInit(IntAllocator(quotient));
bool ok = false;- In
Int.c:1639:
// mutating the outputs, so any input that aliases an output is cloned first.
Int dividend_copy = IntInit(IntAllocator(quotient));
Int divisor_copy = IntInit(IntAllocator(quotient));
bool ok = false;- In
Int.c:1735:
bool int_div(Int *result, const Int *dividend, const Int *divisor) {
Int remainder = IntInit(IntAllocator(result));
// Quotient written straight into result (int_div_mod is in-place and clones
- In
Int.c:1758:
}
Int quotient = IntInit(IntAllocator(result));
Int remainder = IntInit(IntAllocator(result));- In
Int.c:1759:
Int quotient = IntInit(IntAllocator(result));
Int remainder = IntInit(IntAllocator(result));
if (!int_div_mod("ient, &remainder, dividend, divisor)) {- In
Int.c:1778:
bool int_div_u64(Int *result, const Int *dividend, u64 divisor) {
Int divisor_value = IntInit(IntAllocator(dividend));
if (!int_try_from_u64(&divisor_value, divisor, IntAllocator(dividend))) {- In
Int.c:1791:
bool int_div_i64(Int *result, const Int *dividend, i64 divisor) {
Int divisor_value = IntInit(IntAllocator(dividend));
if (!int_try_from_i64_with_allocator(&divisor_value, divisor, IntAllocator(dividend))) {- In
Int.c:1804:
bool int_div_exact_u64(Int *result, const Int *dividend, u64 divisor) {
Int divisor_value = IntInit(IntAllocator(dividend));
if (!int_try_from_u64(&divisor_value, divisor, IntAllocator(dividend))) {- In
Int.c:1817:
bool int_div_exact_i64(Int *result, const Int *dividend, i64 divisor) {
Int divisor_value = IntInit(IntAllocator(dividend));
if (!int_try_from_i64_with_allocator(&divisor_value, divisor, IntAllocator(dividend))) {- In
Int.c:1830:
bool int_div_mod_u64(Int *quotient, Int *remainder, const Int *dividend, u64 divisor) {
Int divisor_value = IntInit(IntAllocator(dividend));
if (!int_try_from_u64(&divisor_value, divisor, IntAllocator(dividend))) {- In
Int.c:1843:
bool int_div_mod_i64(Int *quotient, Int *remainder, const Int *dividend, i64 divisor) {
Int divisor_value = IntInit(IntAllocator(dividend));
if (!int_try_from_i64_with_allocator(&divisor_value, divisor, IntAllocator(dividend))) {- In
Int.c:1864:
}
Int divisor_value = IntInit(IntAllocator(dividend));
Int remainder = IntInit(IntAllocator(quotient));
u64 rem = 0;- In
Int.c:1865:
Int divisor_value = IntInit(IntAllocator(dividend));
Int remainder = IntInit(IntAllocator(quotient));
u64 rem = 0;- In
Int.c:1887:
bool int_mod(Int *result, const Int *dividend, const Int *divisor) {
Int quotient = IntInit(IntAllocator(result));
// Remainder written straight into result (int_div_mod is in-place and clones
- In
Int.c:1901:
bool int_mod_u64_into(Int *result, const Int *dividend, u64 divisor) {
Int quotient = IntInit(IntAllocator(result));
bool ok = int_div_mod_u64("ient, result, dividend, divisor);- In
Int.c:1909:
bool int_mod_i64_into(Int *result, const Int *dividend, i64 divisor) {
Int quotient = IntInit(IntAllocator(result));
bool ok = int_div_mod_i64("ient, result, dividend, divisor);- In
Int.c:1924:
}
Int quotient = IntInit(IntAllocator(value));
u64 rem = int_div_u64_rem("ient, value, modulus);- In
Int.c:1936:
ValidateInt(b);
Int x = IntInit(IntAllocator(a));
Int y = IntInit(IntAllocator(b));- In
Int.c:1937:
Int x = IntInit(IntAllocator(a));
Int y = IntInit(IntAllocator(b));
if (!int_try_clone_value(&x, a) || !int_try_clone_value(&y, b)) {- In
Int.c:1946:
while (!IntIsZero(&y)) {
Int r = IntInit(IntAllocator(result));
if (!int_mod(&r, &x, &y)) {- In
Int.c:1970:
if (IntIsZero(a) || IntIsZero(b)) {
Int zero = IntInit(IntAllocator(result));
int_replace(result, &zero);
return true;- In
Int.c:1975:
}
Int gcd = IntInit(IntAllocator(result));
Int quotient = IntInit(IntAllocator(result));
Int lcm = IntInit(IntAllocator(result));- In
Int.c:1976:
Int gcd = IntInit(IntAllocator(result));
Int quotient = IntInit(IntAllocator(result));
Int lcm = IntInit(IntAllocator(result));- In
Int.c:1977:
Int gcd = IntInit(IntAllocator(result));
Int quotient = IntInit(IntAllocator(result));
Int lcm = IntInit(IntAllocator(result));
if (!IntGCD(&gcd, a, b) || !int_div("ient, a, &gcd) || !int_mul(&lcm, "ient, b)) {- In
Int.c:2006:
if (IntIsZero(value)) {
Int zero_root = IntInit(IntAllocator(root));
Int zero_rem = IntInit(IntAllocator(remainder));- In
Int.c:2007:
if (IntIsZero(value)) {
Int zero_root = IntInit(IntAllocator(root));
Int zero_rem = IntInit(IntAllocator(remainder));
int_replace(root, &zero_root);- In
Int.c:2014:
}
if (degree == 1) {
Int exact_root = IntInit(IntAllocator(root));
Int zero_rem = IntInit(IntAllocator(remainder));- In
Int.c:2015:
if (degree == 1) {
Int exact_root = IntInit(IntAllocator(root));
Int zero_rem = IntInit(IntAllocator(remainder));
if (!IntTryClone(&exact_root, value)) {- In
Int.c:2029:
u64 bits = IntBitLength(value);
u64 high_shift = bits / degree;
Int low = IntInit(IntAllocator(root));
Int high = IntInit(IntAllocator(root));
Int best = IntInit(IntAllocator(root));- In
Int.c:2030:
u64 high_shift = bits / degree;
Int low = IntInit(IntAllocator(root));
Int high = IntInit(IntAllocator(root));
Int best = IntInit(IntAllocator(root));
Int one = IntInit(IntAllocator(root));- In
Int.c:2031:
Int low = IntInit(IntAllocator(root));
Int high = IntInit(IntAllocator(root));
Int best = IntInit(IntAllocator(root));
Int one = IntInit(IntAllocator(root));- In
Int.c:2032:
Int high = IntInit(IntAllocator(root));
Int best = IntInit(IntAllocator(root));
Int one = IntInit(IntAllocator(root));
if ((bits % degree) != 0) {- In
Int.c:2058:
while (IntLE(&low, &high)) {
Int sum = IntInit(IntAllocator(root));
Int mid = IntInit(IntAllocator(root));
Int mid_pow = IntInit(IntAllocator(root));- In
Int.c:2059:
while (IntLE(&low, &high)) {
Int sum = IntInit(IntAllocator(root));
Int mid = IntInit(IntAllocator(root));
Int mid_pow = IntInit(IntAllocator(root));
int cmp = 0;- In
Int.c:2060:
Int sum = IntInit(IntAllocator(root));
Int mid = IntInit(IntAllocator(root));
Int mid_pow = IntInit(IntAllocator(root));
int cmp = 0;- In
Int.c:2087:
if (cmp <= 0) {
Int next = IntInit(IntAllocator(root));
IntDeinit(&best);- In
Int.c:2113:
low = next;
} else {
Int next = IntInit(IntAllocator(root));
if (IntEQ(&mid, &one) || IntIsZero(&mid)) {- In
Int.c:2117:
if (IntEQ(&mid, &one) || IntIsZero(&mid)) {
IntDeinit(&high);
high = IntInit(IntAllocator(root));
} else {
if (!int_sub(&next, &mid, &one)) {- In
Int.c:2139:
{
Int power = IntInit(IntAllocator(root));
Int rem = IntInit(IntAllocator(remainder));- In
Int.c:2140:
{
Int power = IntInit(IntAllocator(root));
Int rem = IntInit(IntAllocator(remainder));
if (!int_pow_u64(&power, &best, degree) || !int_sub(&rem, value, &power)) {- In
Int.c:2165:
bool IntRoot(Int *result, const Int *value, u64 degree) {
Int root = IntInit(IntAllocator(result));
Int remainder = IntInit(IntAllocator(result));- In
Int.c:2166:
bool IntRoot(Int *result, const Int *value, u64 degree) {
Int root = IntInit(IntAllocator(result));
Int remainder = IntInit(IntAllocator(result));
if (!IntRootRem(&root, &remainder, value, degree)) {- In
Int.c:2190:
ValidateInt(value);
Int root = IntInit(IntAllocator(value));
Int remainder = IntInit(IntAllocator(value));
bool result = false;- In
Int.c:2191:
Int root = IntInit(IntAllocator(value));
Int remainder = IntInit(IntAllocator(value));
bool result = false;- In
Int.c:2220:
for (u64 degree = 2; degree <= max_degree; degree++) {
Int root = IntInit(IntAllocator(value));
Int remainder = IntInit(IntAllocator(value));
bool exact = false;- In
Int.c:2221:
for (u64 degree = 2; degree <= max_degree; degree++) {
Int root = IntInit(IntAllocator(value));
Int remainder = IntInit(IntAllocator(value));
bool exact = false;- In
Int.c:2255:
}
Int aa = IntInit(IntAllocator(a));
Int nn = IntInit(IntAllocator(n));
int result = 1;- In
Int.c:2256:
Int aa = IntInit(IntAllocator(a));
Int nn = IntInit(IntAllocator(n));
int result = 1;- In
Int.c:2330:
// instead of a full division: once both inputs are < modulus, sum < 2*modulus,
// so at most one subtraction reduces it (mirrors IntModSub).
Int ar = IntInit(IntAllocator(result));
Int br = IntInit(IntAllocator(result));
Int sum = IntInit(IntAllocator(result));- In
Int.c:2331:
// so at most one subtraction reduces it (mirrors IntModSub).
Int ar = IntInit(IntAllocator(result));
Int br = IntInit(IntAllocator(result));
Int sum = IntInit(IntAllocator(result));
const Int *ared = a;- In
Int.c:2332:
Int ar = IntInit(IntAllocator(result));
Int br = IntInit(IntAllocator(result));
Int sum = IntInit(IntAllocator(result));
const Int *ared = a;
const Int *bred = b;- In
Int.c:2358:
} else {
int_replace(result, &sum);
sum = IntInit(IntAllocator(result));
}
ok = true;- In
Int.c:2380:
}
Int ar = IntInit(IntAllocator(result));
Int br = IntInit(IntAllocator(result));- In
Int.c:2381:
Int ar = IntInit(IntAllocator(result));
Int br = IntInit(IntAllocator(result));
if (!int_mod(&ar, a, modulus) || !int_mod(&br, b, modulus)) {- In
Int.c:2396:
}
} else {
Int diff = IntInit(IntAllocator(result));
if (!int_sub(&diff, &br, &ar)) {- In
Int.c:2405:
}
if (IntIsZero(&diff)) {
Int zero = IntInit(IntAllocator(result));
int_replace(result, &zero);
} else {- In
Int.c:2438:
// not already < modulus (the common case in modpow/Miller-Rabin/Tonelli loops,
// where operands are already reduced - so both input divisions are skipped).
Int ar = IntInit(IntAllocator(result));
Int br = IntInit(IntAllocator(result));
Int prod = IntInit(IntAllocator(result));- In
Int.c:2439:
// where operands are already reduced - so both input divisions are skipped).
Int ar = IntInit(IntAllocator(result));
Int br = IntInit(IntAllocator(result));
Int prod = IntInit(IntAllocator(result));
const Int *ared = a;- In
Int.c:2440:
Int ar = IntInit(IntAllocator(result));
Int br = IntInit(IntAllocator(result));
Int prod = IntInit(IntAllocator(result));
const Int *ared = a;
const Int *bred = b;- In
Int.c:2480:
}
Int inverse = IntInit(IntAllocator(result));
Int value = IntInit(IntAllocator(result));
bool ok = false;- In
Int.c:2481:
Int inverse = IntInit(IntAllocator(result));
Int value = IntInit(IntAllocator(result));
bool ok = false;- In
Int.c:2515:
}
Int acc = IntInit(IntAllocator(result));
Int base_mod = IntInit(IntAllocator(result));- In
Int.c:2516:
Int acc = IntInit(IntAllocator(result));
Int base_mod = IntInit(IntAllocator(result));
if (!int_try_from_u64(&acc, 1, IntAllocator(result))) {- In
Int.c:2528:
}
Int scratch = IntInit(IntAllocator(result));
while (exponent > 0) {- In
Int.c:2570:
}
Int acc = IntInit(IntAllocator(result));
Int base_mod = IntInit(IntAllocator(result));
Int exp = IntInit(IntAllocator(exponent));- In
Int.c:2571:
Int acc = IntInit(IntAllocator(result));
Int base_mod = IntInit(IntAllocator(result));
Int exp = IntInit(IntAllocator(exponent));- In
Int.c:2572:
Int acc = IntInit(IntAllocator(result));
Int base_mod = IntInit(IntAllocator(result));
Int exp = IntInit(IntAllocator(exponent));
if (!int_try_from_u64(&acc, 1, IntAllocator(result)) || !IntTryClone(&exp, exponent) ||- In
Int.c:2582:
}
Int scratch = IntInit(IntAllocator(result));
while (!IntIsZero(&exp)) {- In
Int.c:2640:
}
Int reduced = IntInit(IntAllocator(result));
SignedInt t = sint_init(IntAllocator(result));
SignedInt new_t = sint_from_u64(1, IntAllocator(result));- In
Int.c:2643:
SignedInt t = sint_init(IntAllocator(result));
SignedInt new_t = sint_from_u64(1, IntAllocator(result));
Int r = IntInit(IntAllocator(modulus));
Int new_r = IntInit(IntAllocator(result));
Int one = int_from_u64(1, IntAllocator(result));- In
Int.c:2644:
SignedInt new_t = sint_from_u64(1, IntAllocator(result));
Int r = IntInit(IntAllocator(modulus));
Int new_r = IntInit(IntAllocator(result));
Int one = int_from_u64(1, IntAllocator(result));
bool ok = false;- In
Int.c:2668:
while (!IntIsZero(&new_r)) {
Int q = IntInit(IntAllocator(result));
Int rem = IntInit(IntAllocator(result));
SignedInt q_new_t = sint_init(IntAllocator(result));- In
Int.c:2669:
while (!IntIsZero(&new_r)) {
Int q = IntInit(IntAllocator(result));
Int rem = IntInit(IntAllocator(result));
SignedInt q_new_t = sint_init(IntAllocator(result));
SignedInt next_t = sint_init(IntAllocator(result));- In
Int.c:2672:
SignedInt q_new_t = sint_init(IntAllocator(result));
SignedInt next_t = sint_init(IntAllocator(result));
Int next_r = IntInit(IntAllocator(result));
if (!int_div_mod(&q, &rem, &r, &new_r) || !sint_mul_unsigned(&q_new_t, &new_t, &q) ||- In
Int.c:2706:
if (IntEQ(&r, &one)) {
Int positive = IntInit(IntAllocator(result));
Int mag_mod = IntInit(IntAllocator(result));- In
Int.c:2707:
if (IntEQ(&r, &one)) {
Int positive = IntInit(IntAllocator(result));
Int mag_mod = IntInit(IntAllocator(result));
if (!int_mod(&mag_mod, &t.magnitude, modulus)) {- In
Int.c:2770:
}
Int a = IntInit(IntAllocator(result));
bool ok = false;- In
Int.c:2779:
if (IntIsZero(&a)) {
Int zero = IntInit(IntAllocator(result));
int_replace(result, &zero);
IntDeinit(&a);- In
Int.c:2809:
}
if (int_mod_u64(modulus, 4) == 3) {
Int exponent = IntInit(IntAllocator(modulus));
Int root = IntInit(IntAllocator(result));- In
Int.c:2810:
if (int_mod_u64(modulus, 4) == 3) {
Int exponent = IntInit(IntAllocator(modulus));
Int root = IntInit(IntAllocator(result));
if (!IntTryClone(&exponent, modulus) || !int_add_u64(&exponent, &exponent, 1) || !IntShiftRight(&exponent, 2) ||- In
Int.c:2827:
{
Int q = IntInit(IntAllocator(modulus));
Int z = IntInit(IntAllocator(modulus));
Int c = IntInit(IntAllocator(result));- In
Int.c:2828:
{
Int q = IntInit(IntAllocator(modulus));
Int z = IntInit(IntAllocator(modulus));
Int c = IntInit(IntAllocator(result));
Int t = IntInit(IntAllocator(result));- In
Int.c:2829:
Int q = IntInit(IntAllocator(modulus));
Int z = IntInit(IntAllocator(modulus));
Int c = IntInit(IntAllocator(result));
Int t = IntInit(IntAllocator(result));
Int r = IntInit(IntAllocator(result));- In
Int.c:2830:
Int z = IntInit(IntAllocator(modulus));
Int c = IntInit(IntAllocator(result));
Int t = IntInit(IntAllocator(result));
Int r = IntInit(IntAllocator(result));
Int exponent = IntInit(IntAllocator(result));- In
Int.c:2831:
Int c = IntInit(IntAllocator(result));
Int t = IntInit(IntAllocator(result));
Int r = IntInit(IntAllocator(result));
Int exponent = IntInit(IntAllocator(result));
u64 m = 0;- In
Int.c:2832:
Int t = IntInit(IntAllocator(result));
Int r = IntInit(IntAllocator(result));
Int exponent = IntInit(IntAllocator(result));
u64 m = 0;- In
Int.c:2913:
while (int_compare_u64(&t, 1) != 0) {
Int t_power = IntInit(IntAllocator(&t));
u64 i = 0;- In
Int.c:2928:
}
Int scratch = IntInit(IntAllocator(result));
for (i = 1; i < m; i++) {- In
Int.c:2958:
{
Int b = IntInit(IntAllocator(&c));
Int b_sq = IntInit(IntAllocator(result));
Int next = IntInit(IntAllocator(result));- In
Int.c:2959:
{
Int b = IntInit(IntAllocator(&c));
Int b_sq = IntInit(IntAllocator(result));
Int next = IntInit(IntAllocator(result));- In
Int.c:2960:
Int b = IntInit(IntAllocator(&c));
Int b_sq = IntInit(IntAllocator(result));
Int next = IntInit(IntAllocator(result));
if (!IntTryClone(&b, &c)) {- In
Int.c:2978:
for (u64 j = 0; j + i + 1 < m; j++) {
Int square = IntInit(IntAllocator(result));
if (!IntSquareMod(&square, &b, modulus)) {- In
Int.c:3029:
return false;
}
next = IntInit(IntAllocator(result));
if (!IntModMul(&next, &t, &b_sq, modulus)) {
IntDeinit(&b);- In
Int.c:3102:
{
Int d = IntInit(IntAllocator(value));
Int n_minus_one = IntInit(IntAllocator(value));
u64 s = 0;- In
Int.c:3103:
{
Int d = IntInit(IntAllocator(value));
Int n_minus_one = IntInit(IntAllocator(value));
u64 s = 0;
bool probable = true;- In
Int.c:3128:
for (u64 i = 0; i < (u64)(sizeof(bases) / sizeof(bases[0])); i++) {
Int base = IntInit(IntAllocator(value));
Int x = IntInit(IntAllocator(value));- In
Int.c:3129:
for (u64 i = 0; i < (u64)(sizeof(bases) / sizeof(bases[0])); i++) {
Int base = IntInit(IntAllocator(value));
Int x = IntInit(IntAllocator(value));
if (!int_try_from_u64(&base, bases[i], IntAllocator(value))) {- In
Int.c:3162:
for (u64 r = 1; r < s; r++) {
Int next = IntInit(IntAllocator(value));
if (!IntSquareMod(&next, &x, value)) {- In
Int.c:3206:
if (int_compare_u64(value, 1) <= 0) {
Int two = IntInit(IntAllocator(result));
if (!int_try_from_u64(&two, 2, IntAllocator(result))) {- In
Int.c:3216:
}
Int candidate = IntInit(IntAllocator(result));
if (!IntTryClone(&candidate, value)) {- In
Int.c:3228:
}
if (int_compare_u64(&candidate, 2) <= 0) {
Int two = IntInit(IntAllocator(result));
if (!int_try_from_u64(&two, 2, IntAllocator(result))) {- In
Float.c:77:
} else if (binexp < 0) {
u64 n = (u64)(-(i64)binexp);
Int five = IntInit(alloc);
Int pow5 = IntInit(alloc);
Int sig = IntInit(alloc);- In
Float.c:78:
u64 n = (u64)(-(i64)binexp);
Int five = IntInit(alloc);
Int pow5 = IntInit(alloc);
Int sig = IntInit(alloc);
if (!int_try_from_u64(&five, 5u, alloc) || !IntPow(&pow5, &five, n) ||- In
Float.c:79:
Int five = IntInit(alloc);
Int pow5 = IntInit(alloc);
Int sig = IntInit(alloc);
if (!int_try_from_u64(&five, 5u, alloc) || !IntPow(&pow5, &five, n) ||
!int_mul(&sig, &out->significand, &pow5)) {- In
Float.c:200:
{
u64 places = (u64)(value->exponent - target_exponent);
Int factor = IntInit(FloatAllocator(value));
Int scaled = IntInit(FloatAllocator(value));- In
Float.c:201:
u64 places = (u64)(value->exponent - target_exponent);
Int factor = IntInit(FloatAllocator(value));
Int scaled = IntInit(FloatAllocator(value));
if (!float_pow10(&factor, places, FloatAllocator(value)) || !int_mul(&scaled, &value->significand, &factor)) {- In
Float.c:278:
{
Allocator *alloc = FloatAllocator(value);
Int ten = IntInit(alloc);
Int q = IntInit(alloc);
Int r = IntInit(alloc);- In
Float.c:279:
Allocator *alloc = FloatAllocator(value);
Int ten = IntInit(alloc);
Int q = IntInit(alloc);
Int r = IntInit(alloc);- In
Float.c:280:
Int ten = IntInit(alloc);
Int q = IntInit(alloc);
Int r = IntInit(alloc);
if (int_try_from_u64(&ten, 10, alloc)) {- In
Float.c:437:
ValidateFloat(value);
Int temp = IntInit(IntAllocator(result));
if (FloatIsNegative(value)) {- In
Float.c:451:
if (value->exponent >= 0) {
Int factor = IntInit(FloatAllocator(value));
if (!IntTryClone(&temp, &value->significand) ||- In
Float.c:468:
{
u64 places = (u64)(-value->exponent);
Int factor = IntInit(FloatAllocator(value));
bool ok = false;- In
Float.c:1193:
bool float_div(Float *result, const Float *a, const Float *b, u64 precision) {
Float temp = FloatInit(FloatAllocator(result));
Int scale = IntInit(FloatAllocator(result));
Int scaled = IntInit(FloatAllocator(result));- In
Float.c:1194:
Float temp = FloatInit(FloatAllocator(result));
Int scale = IntInit(FloatAllocator(result));
Int scaled = IntInit(FloatAllocator(result));
ValidateFloat(result);- In
Type.c:175:
Float neg = FloatFromStr("-5", &alloc.base);
Int out = IntInit(&alloc.base);
bool ok = (FloatToInt(&out, &neg) == false);- In
Type.c:207:
.exponent = -1,
};
Int result = IntInit(&alloc.base);
bool ok = FloatToInt(&result, &value);- In
Type.c:228:
Float value = FloatFromStr("120", &alloc.base);
Int result = IntInit(&alloc.base);
bool ok = FloatToInt(&result, &value);- In
Type.c:267:
Float value = FloatFromStr("-7", &alloc.base);
Int result = IntInit(&alloc.base);
bool ok = FloatToInt(&result, &value);- In
Convert.c:106:
Float value = FloatFromStr("1234500e-2", ALLOCATOR_OF(&alloc));
Int result_value = IntInit(ALLOCATOR_OF(&alloc));
Str text = StrInit(ALLOCATOR_OF(&alloc));- In
Convert.c:714:
Float v = FloatFromStr("1e3", &dbg.base); // exponent 3 > 0 -> pow10
Int r = IntInit(&dbg.base);
bool ok = FloatToInt(&r, &v); // drives float_pow10 + success path
- In
Compare.c:263:
DefaultAllocator alloc = DefaultAllocatorInit();
Int zero = IntInit(&alloc.base);
int cmp = int_compare_i64(&zero, (i64)0);- In
Type.c:17:
bool test_int_init(void) {
WriteFmt("Testing IntInit\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Type.c:21:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntInit(&alloc.base);
bool result = IntIsZero(&value);- In
Type.c:81:
alloc.base.retry_limit = 5;
Int original = IntInit(&alloc);
BitVecPush(&original.bits, true);- In
Type.c:121:
Int a = IntFrom(255, &alloc.base);
Int b = IntFrom(1, &alloc.base);
Int sum = IntInit(&alloc.base);
IntAdd(&sum, &a, &b);- In
Math.c:113:
Int a = IntFrom(255, &alloc.base);
Int b = IntFrom(1, &alloc.base);
Int result_value = IntInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:137:
Int base = IntFrom(40, &alloc.base);
Int rhs = IntFrom(2, &alloc.base);
Int result_value = IntInit(&alloc.base);
Int huge = IntFromStr("123456789012345678901234567890", &alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:170:
Int a = IntFrom(256, &alloc.base);
Int b = IntFrom(1, &alloc.base);
Int result_value = IntInit(&alloc.base);
bool result = IntSub(&result_value, &a, &b);- In
Math.c:189:
Int base = IntFrom(40, &alloc.base);
Int rhs = IntFrom(2, &alloc.base);
Int result_value = IntInit(&alloc.base);
Int preserved = IntFrom(99, &alloc.base);
Int huge = IntFromStr("12345678901234567890", &alloc.base);- In
Math.c:246:
Int a = IntFrom(21, &alloc.base);
Int b = IntFrom(6, &alloc.base);
Int result_value = IntInit(&alloc.base);
IntMul(&result_value, &a, &b);- In
Math.c:265:
Int value = IntFromStr("12345678901234567890", &alloc.base);
Int result_value = IntInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:287:
Int a = IntFrom(0, &alloc.base);
Int b = IntFrom(12345, &alloc.base);
Int result_value = IntInit(&alloc.base);
IntMul(&result_value, &a, &b);- In
Math.c:307:
Int value = IntFrom(12345, &alloc.base);
Int result_value = IntInit(&alloc.base);
IntSquare(&result_value, &value);- In
Math.c:326:
Int base = IntFrom(7, &alloc.base);
Int exponent = IntFrom(20, &alloc.base);
Int result_value = IntInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:352:
Int dividend = IntFromStr("12345678901234567890", &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
Str qtext = StrInit(&alloc.base);- In
Math.c:353:
Int dividend = IntFromStr("12345678901234567890", &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
Str qtext = StrInit(&alloc.base);- In
Math.c:376:
Int dividend = IntFrom(126, &alloc.base);
Int result_value = IntInit(&alloc.base);
IntDiv(&result_value, ÷nd, 10u);- In
Math.c:394:
Int dividend = IntFromStr("12345678901234567890", &alloc.base);
Int result_value = IntInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:433:
Int dividend = IntFromStr("12345678901234567890", &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:434:
Int dividend = IntFromStr("12345678901234567890", &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:457:
Int dividend = IntFrom(126, &alloc.base);
Int result_value = IntInit(&alloc.base);
IntMod(&result_value, ÷nd, 10u);- In
Math.c:475:
Int value = IntFromStr("12345678901234567890", &alloc.base);
Int remainder = IntInit(&alloc.base);
IntMod(&remainder, &value, 97u);- In
Math.c:493:
Int a = IntFrom(48, &alloc.base);
Int b = IntFrom(18, &alloc.base);
Int result_value = IntInit(&alloc.base);
IntGCD(&result_value, &a, &b);- In
Math.c:513:
Int a = IntFrom(21, &alloc.base);
Int b = IntFrom(6, &alloc.base);
Int result_value = IntInit(&alloc.base);
IntLCM(&result_value, &a, &b);- In
Math.c:532:
Int value = IntFrom(4096, &alloc.base);
Int result_value = IntInit(&alloc.base);
IntRoot(&result_value, &value, 4);- In
Math.c:550:
Int value = IntFrom(200, &alloc.base);
Int root = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:551:
Int value = IntFrom(200, &alloc.base);
Int root = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
IntRootRem(&root, &remainder, &value, 3);- In
Math.c:571:
Int value = IntFrom(200, &alloc.base);
Int result_value = IntInit(&alloc.base);
IntSqrt(&result_value, &value);- In
Math.c:589:
Int value = IntFrom(200, &alloc.base);
Int root = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:590:
Int value = IntFrom(200, &alloc.base);
Int root = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
IntSqrtRem(&root, &remainder, &value);- In
Math.c:669:
Int value = IntFrom(12345, &alloc.base);
Int mod = IntFrom(97, &alloc.base);
Int result_value = IntInit(&alloc.base);
IntSquareMod(&result_value, &value, &mod);- In
Math.c:690:
Int b = IntFrom(250, &alloc.base);
Int m = IntFrom(13, &alloc.base);
Int result_value = IntInit(&alloc.base);
IntModAdd(&result_value, &a, &b, &m);- In
Math.c:712:
Int b = IntFrom(9, &alloc.base);
Int m = IntFrom(13, &alloc.base);
Int result_value = IntInit(&alloc.base);
IntModSub(&result_value, &a, &b, &m);- In
Math.c:734:
Int b = IntFrom(456, &alloc.base);
Int m = IntFrom(97, &alloc.base);
Int result_value = IntInit(&alloc.base);
IntModMul(&result_value, &a, &b, &m);- In
Math.c:756:
Int b = IntFrom(3, &alloc.base);
Int m = IntFrom(13, &alloc.base);
Int result_value = IntInit(&alloc.base);
Int check = IntInit(&alloc.base);- In
Math.c:757:
Int m = IntFrom(13, &alloc.base);
Int result_value = IntInit(&alloc.base);
Int check = IntInit(&alloc.base);
bool result = IntModDiv(&result_value, &a, &b, &m);- In
Math.c:781:
Int base = IntFrom(7, &alloc.base);
Int mod = IntFrom(13, &alloc.base);
Int result_value = IntInit(&alloc.base);
IntPowMod(&result_value, &base, 20u, &mod);- In
Math.c:802:
Int exp = IntFrom(13, &alloc.base);
Int mod = IntFrom(497, &alloc.base);
Int result_value = IntInit(&alloc.base);
IntPowMod(&result_value, &base, &exp, &mod);- In
Math.c:823:
Int value = IntFrom(3, &alloc.base);
Int mod = IntFrom(11, &alloc.base);
Int result_value = IntInit(&alloc.base);
Int check = IntInit(&alloc.base);- In
Math.c:824:
Int mod = IntFrom(11, &alloc.base);
Int result_value = IntInit(&alloc.base);
Int check = IntInit(&alloc.base);
bool result = IntModInv(&result_value, &value, &mod);- In
Math.c:847:
Int value = IntFrom(10, &alloc.base);
Int mod = IntFrom(13, &alloc.base);
Int root = IntInit(&alloc.base);
Int check = IntInit(&alloc.base);- In
Math.c:848:
Int mod = IntFrom(13, &alloc.base);
Int root = IntInit(&alloc.base);
Int check = IntInit(&alloc.base);
bool result = IntModSqrt(&root, &value, &mod);- In
Math.c:904:
Int value = IntFromStr("1000000000", &alloc.base);
Int next = IntInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:988:
Int dividend = IntFrom(1, &alloc.base);
Int divisor = IntInit(&alloc.base);
Int quotient = IntFrom(99, &alloc.base);
Int remainder = IntFrom(77, &alloc.base);- In
Math.c:1066:
Int a = IntFrom(10, &alloc.base);
Int b = IntFrom(3, &alloc.base);
Int m = IntInit(&alloc.base);
Int result_value = IntFrom(99, &alloc.base);- In
Math.c:1107:
Int base = IntFrom(2, &alloc.base);
Int mod = IntInit(&alloc.base);
Int result_value = IntInit(&alloc.base);- In
Math.c:1108:
Int base = IntFrom(2, &alloc.base);
Int mod = IntInit(&alloc.base);
Int result_value = IntInit(&alloc.base);
IntPowMod(&result_value, &base, 8u, &mod);- In
Math.c:1122:
Int base = IntFrom(2, &alloc.base);
Int exp = IntFrom(8, &alloc.base);
Int mod = IntInit(&alloc.base);
Int result_value = IntFrom(99, &alloc.base);- In
Math.c:1150:
Int mod = IntFrom(7, &alloc.base);
Int root = IntFrom(99, &alloc.base);
Int check = IntInit(&alloc.base);
bool result = IntModSqrt(&root, &value, &mod);- In
Math.c:1207:
Int mod = IntFrom(17, &alloc.base);
Int root = IntFrom(99, &alloc.base);
Int check = IntInit(&alloc.base);
bool result = IntModSqrt(&root, &value, &mod);- In
Math.c:1237:
Int mod = IntFrom(17, &alloc.base);
Int root = IntFrom(99, &alloc.base);
Int check = IntInit(&alloc.base);
bool result = IntModSqrt(&root, &value, &mod);- In
Math.c:1267:
Int mod = IntFrom(97, &alloc.base);
Int root = IntFrom(99, &alloc.base);
Int check = IntInit(&alloc.base);
bool result = IntModSqrt(&root, &value, &mod);- In
Math.c:1296:
Int mod = IntFrom(257, &alloc.base);
Int root = IntFrom(99, &alloc.base);
Int check = IntInit(&alloc.base);
bool result = IntModSqrt(&root, &value, &mod);- In
Math.c:1322:
Int mod = IntFrom(13, &alloc.base);
Int root = IntFrom(99, &alloc.base);
Int check = IntInit(&alloc.base);
bool result = IntModSqrt(&root, &value, &mod);- In
Math.c:1482:
Int value = IntFrom(4, &alloc.base);
Int mod = IntInit(&alloc.base);
Int root = IntFrom(99, &alloc.base);- In
Math.c:1508:
Int mod = IntFrom(7, &alloc.base);
Int root = IntFrom(99, &alloc.base);
Int check = IntInit(&alloc.base);
bool result = IntModSqrt(&root, &value, &mod);- In
Math.c:1539:
Int a = IntFrom((u64)123456789u, &alloc.base);
Int b = IntFrom((u64)987654321u, &alloc.base);
Int product = IntInit(&alloc.base);
bool ok = IntMul(&product, &a, &b);- In
Math.c:1563:
Int a = IntFrom((u64)999u, &alloc.base);
Int zero = IntInit(&alloc.base);
Int product = IntInit(&alloc.base);- In
Math.c:1564:
Int a = IntFrom((u64)999u, &alloc.base);
Int zero = IntInit(&alloc.base);
Int product = IntInit(&alloc.base);
bool ok = IntMul(&product, &a, &zero);- In
Math.c:1605:
Int base = IntFrom(7, &alloc.base);
Int result = IntInit(&alloc.base);
// exponent 0 -> 1 (loop body never runs)
- In
Math.c:1665:
Int b = IntFrom(8, &alloc.base);
Int result = IntInit(&alloc.base);
IntGCD(&result, NULL, &b);- In
Math.c:1686:
Int a = IntFrom(12, &alloc.base);
Int result = IntInit(&alloc.base);
IntGCD(&result, &a, NULL);- In
Math.c:1763:
Int a = IntFrom(4, &alloc.base);
Int b = IntFrom(1, &alloc.base);
Int result_value = IntInit(&alloc.base);
bool ok = IntSub(&result_value, &a, &b);- In
Math.c:1823:
DefaultAllocator alloc = DefaultAllocatorInit();
Int quotient = IntInit(&alloc.base);
int_div_u64_rem("ient, NULL, 7);- In
Math.c:1927:
Int ones = IntFromBinary("1111111", &alloc.base); // 127
Int one = IntFrom(1u, &alloc.base);
Int sum = IntInit(&alloc.base);
IntAdd(&sum, &ones, &one);- In
Math.c:1977:
Int value = IntFrom(10000, &alloc.base);
Int root = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:1978:
Int value = IntFrom(10000, &alloc.base);
Int root = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
bool ok = IntRootRem(&root, &remainder, &value, 2);- In
Math.c:2000:
Int value = IntFrom(1000, &alloc.base);
Int root = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:2001:
Int value = IntFrom(1000, &alloc.base);
Int root = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
bool ok = IntRootRem(&root, &remainder, &value, 3);- In
Math.c:2024:
Int value = IntFrom(1001, &alloc.base);
Int root = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:2025:
Int value = IntFrom(1001, &alloc.base);
Int root = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
bool ok = IntRootRem(&root, &remainder, &value, 3);- In
Math.c:2047:
Int value = IntFrom(999, &alloc.base);
Int root = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:2048:
Int value = IntFrom(999, &alloc.base);
Int root = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
bool ok = IntRootRem(&root, &remainder, &value, 3);- In
Math.c:2070:
Int value = IntFrom(1000000, &alloc.base);
Int root = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:2071:
Int value = IntFrom(1000000, &alloc.base);
Int root = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
bool ok = IntRootRem(&root, &remainder, &value, 4);- In
Math.c:2102:
Int base = IntFrom(7, &alloc.base);
Int exp = IntFrom(5, &alloc.base);
Int power = IntInit(&alloc.base);
// 7**5 == 16807.
- In
Math.c:2159:
Int dividend = IntFrom(1000, &alloc.base);
Int quotient = IntInit(&alloc.base);
// 1000 / 7 == 142 (floor).
- In
Math.c:2205:
Int dividend = IntFrom(1001, &alloc.base);
Int quotient = IntInit(&alloc.base);
// 1001 / 7 == 143 exactly.
- In
Math.c:2421:
Int dividend = IntFrom(123456789, &alloc.base);
Int result_value = IntInit(&alloc.base);
bool ok = int_div_exact_u64(&result_value, ÷nd, 3u);- In
Math.c:2445:
Int dividend = IntFromStr("12345678901234567890", &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
Str qtext = StrInit(&alloc.base);- In
Math.c:2446:
Int dividend = IntFromStr("12345678901234567890", &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
Str qtext = StrInit(&alloc.base);- In
Math.c:2475:
Int dividend = IntFromStr("12345678901234567890", &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
Str qtext = StrInit(&alloc.base);- In
Math.c:2476:
Int dividend = IntFromStr("12345678901234567890", &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
Str qtext = StrInit(&alloc.base);- In
Math.c:2507:
Int dividend = IntFromStr("12345678901234567890", &alloc.base);
Int result_value = IntInit(&alloc.base);
bool ok = int_mod_i64_into(&result_value, ÷nd, (i64)13);- In
Math.c:2535:
Int base = IntFrom(7, &alloc.base);
Int modulus = IntFrom(1000000007, &alloc.base);
Int result_value = IntInit(&alloc.base);
bool ok = int_pow_i64_mod(&result_value, &base, (i64)13, &modulus);- In
Math.c:2562:
Int base = IntFrom(7, &alloc.base);
Int modulus = IntFrom(1000000007, &alloc.base);
Int result_value = IntInit(&alloc.base);
bool ok = int_pow_i64_mod(&result_value, &base, (i64)0, &modulus);- In
Math.c:2586:
Int value = IntFrom(4096, &alloc.base);
Int result_value = IntInit(&alloc.base);
bool ok = IntRoot(&result_value, &value, 4);- In
Math.c:2612:
DefaultAllocator alloc = DefaultAllocatorInit();
Int zero = IntInit(&alloc.base);
bool result = (IntIsOdd(&zero) == false);- In
Math.c:2634:
Int dividend = IntFrom((u64)100u, &alloc.base);
Int result = IntInit(&alloc.base);
bool ok = IntMod(&result, ÷nd, (unsigned long)7u);- In
Math.c:2710:
Int value = IntFrom(3, &alloc.base);
Int mod = IntFrom(11, &alloc.base);
Int result = IntInit(&alloc.base);
Int check = IntInit(&alloc.base);- In
Math.c:2711:
Int mod = IntFrom(11, &alloc.base);
Int result = IntInit(&alloc.base);
Int check = IntInit(&alloc.base);
bool ok = IntModInv(&result, &value, &mod);- In
Math.c:2744:
Int value = IntFrom(5, &alloc.base);
Int mod = IntFrom(11, &alloc.base);
Int result = IntInit(&alloc.base);
Int check = IntInit(&alloc.base);- In
Math.c:2745:
Int mod = IntFrom(11, &alloc.base);
Int result = IntInit(&alloc.base);
Int check = IntInit(&alloc.base);
bool ok = IntModInv(&result, &value, &mod);- In
Math.c:2815:
Int dividend = IntFrom(127, &alloc.base);
Int quotient = IntInit(&alloc.base);
bool ok = IntDivExact("ient, ÷nd, 10u);- In
Math.c:2832:
Int dividend = IntFrom(127, &alloc.base);
Int quotient = IntInit(&alloc.base);
bool ok = IntDivExact("ient, ÷nd, (i64)10);- In
Math.c:2852:
Int dividend = IntFrom(127, &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:2853:
Int dividend = IntFrom(127, &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
bool ok = IntDivMod("ient, &remainder, ÷nd, 0u);- In
Math.c:2871:
Int dividend = IntFrom(127, &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:2872:
Int dividend = IntFrom(127, &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
bool ok = IntDivMod("ient, &remainder, ÷nd, (i64)0);- In
Math.c:2893:
Int dividend = IntFrom(127, &alloc.base);
Int result_value = IntInit(&alloc.base);
bool ok = IntMod(&result_value, ÷nd, 0u);- In
Math.c:2910:
Int dividend = IntFrom(127, &alloc.base);
Int result_value = IntInit(&alloc.base);
bool ok = IntMod(&result_value, ÷nd, (i64)0);- In
Math.c:2935:
IntShiftLeft(&value, 50); // 2^50
Int root = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:2936:
Int root = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
bool ok = IntSqrtRem(&root, &remainder, &value);- In
Math.c:2984:
Int value = IntFrom(2, &alloc.base);
Int mod = IntFrom(17, &alloc.base);
Int root = IntInit(&alloc.base);
Int check = IntInit(&alloc.base);- In
Math.c:2985:
Int mod = IntFrom(17, &alloc.base);
Int root = IntInit(&alloc.base);
Int check = IntInit(&alloc.base);
bool ok = IntModSqrt(&root, &value, &mod);- In
Math.c:3154:
Int dividend = IntFromStr("12345678901234567890123456789", &alloc.base);
Int divisor = IntFromStr("987654321987654321", &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:3155:
Int divisor = IntFromStr("987654321987654321", &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
bool ok = int_div_mod("ient, &remainder, ÷nd, &divisor);- In
Math.c:3189:
Int dividend = IntFromStr("1000000007", &alloc.base);
Int divisor = IntFromStr("97", &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:3190:
Int divisor = IntFromStr("97", &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
bool ok = int_div_mod("ient, &remainder, ÷nd, &divisor);- In
Math.c:3218:
Int dividend = IntFromStr("11975308533", &alloc.base);
Int divisor = IntFromStr("97", &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:3219:
Int divisor = IntFromStr("97", &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
bool ok = int_div_mod("ient, &remainder, ÷nd, &divisor);- In
Math.c:3246:
Int dividend = IntFromStr("42", &alloc.base);
Int divisor = IntFromStr("1000", &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:3247:
Int divisor = IntFromStr("1000", &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
bool ok = int_div_mod("ient, &remainder, ÷nd, &divisor);- In
Math.c:3274:
Int dividend = IntFromStr("12345", &alloc.base);
Int divisor = IntInit(&alloc.base); /* zero */
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:3275:
Int divisor = IntInit(&alloc.base); /* zero */
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
bool ok = int_div_mod("ient, &remainder, ÷nd, &divisor);- In
Math.c:3299:
Int dividend = IntFromStr("100", &alloc.base);
Int divisor = IntFromStr("7", &alloc.base);
Int remainder = IntInit(&alloc.base);
/* Must abort inside int_div_mod via ValidateInt(quotient). */- In
Math.c:3321:
Int dividend = IntFromStr("100", &alloc.base);
Int divisor = IntFromStr("7", &alloc.base);
Int quotient = IntInit(&alloc.base);
/* Must abort inside int_div_mod via ValidateInt(remainder). */- In
Math.c:3383:
Int exp = IntFrom(13, &alloc.base);
Int mod = IntFrom(497, &alloc.base);
Int result_value = IntInit(&alloc.base);
bool ok = int_pow_mod(&result_value, &base, &exp, &mod);- In
Math.c:3404:
Int exp = IntFrom(987654321u, &dbg.base); // many set bits + bits
Int mod = IntFrom(1000000007u, &dbg.base);
Int result_value = IntInit(&dbg.base);
bool ok = int_pow_mod(&result_value, &base, &exp, &mod);- In
Math.c:3434:
Int value = IntFrom(0, &alloc.base);
Int next = IntInit(&alloc.base);
bool ok = IntNextPrime(&next, &value);- In
Math.c:3462:
Int value = IntFrom(10, &alloc.base);
Int next = IntInit(&alloc.base);
bool ok = IntNextPrime(&next, &value);- In
Math.c:3485:
Int value = IntFrom(9, &alloc.base);
Int next = IntInit(&alloc.base);
bool ok = IntNextPrime(&next, &value);- In
Math.c:3530:
Int b = IntFrom(5, &alloc.base);
Int m = IntFrom(13, &alloc.base);
Int result_value = IntInit(&alloc.base);
bool ok = IntModSub(&result_value, &a, &b, &m);- In
Math.c:3576:
Int base = IntFrom(3, &alloc.base);
Int mod = IntFrom(17, &alloc.base);
Int result_value = IntInit(&alloc.base);
bool ok = IntPowMod(&result_value, &base, 13u, &mod);- In
Math.c:3598:
Int base = IntFrom(123456789, &alloc.base);
Int mod = IntFrom(1000000007, &alloc.base);
Int result_value = IntInit(&alloc.base);
bool ok = IntPowMod(&result_value, &base, 0u, &mod);- In
Math.c:3622:
Int base = IntFrom(2, &alloc.base);
Int mod = IntFrom(1000000007, &alloc.base);
Int result_value = IntInit(&alloc.base);
bool ok = IntPowMod(&result_value, &base, 64u, &mod);- In
Math.c:3656:
DefaultAllocator alloc = DefaultAllocatorInit();
Int result_value = IntInit(&alloc.base);
Int mod = IntFrom(7, &alloc.base);- In
Math.c:3671:
DefaultAllocator alloc = DefaultAllocatorInit();
Int result_value = IntInit(&alloc.base);
Int base = IntFrom(2, &alloc.base);- In
Math.c:3686:
Int x = IntFrom(123456u, a);
Int y = IntFrom(7891011u, a);
Int r = IntInit(a);
bool ok = IntMul(&r, &x, &y);- In
Convert.c:340:
Int parsed = IntFromBinary("10a1", ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromBinary(&value, "10a1");- In
Convert.c:358:
Int parsed = IntFromStr("12x3", ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromStr(&value, "12x3");- In
Convert.c:376:
Int parsed = IntFromHexStr("12g3", ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromHexStr(&value, "12g3");- In
Convert.c:394:
Int parsed = IntFromStrRadix("102", 2, ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromStrRadix(&value, "102", 2);- In
Convert.c:412:
Int parsed = IntFromStrRadix("10", 1, ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromStrRadix(&value, "10", 1);- In
Convert.c:476:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntInit(ALLOCATOR_OF(&alloc));
IntTryFromBinary(&value, (Zstr)NULL);
IntDeinit(&value);- In
Convert.c:498:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntInit(ALLOCATOR_OF(&alloc));
IntTryFromStr(&value, (Zstr)NULL);
IntDeinit(&value);- In
Convert.c:520:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntInit(ALLOCATOR_OF(&alloc));
IntTryFromStrRadix(&value, (Zstr)NULL, 10);
IntDeinit(&value);- In
Convert.c:542:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntInit(ALLOCATOR_OF(&alloc));
IntTryFromOctStr(&value, (Zstr)NULL);
IntDeinit(&value);- In
Convert.c:564:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntInit(ALLOCATOR_OF(&alloc));
IntTryFromHexStr(&value, (Zstr)NULL);
IntDeinit(&value);- In
Convert.c:618:
Int a = IntFrom((u64)13u, &alloc.base);
Int b = IntFrom((u64)21u, &alloc.base);
Int product = IntInit(&alloc.base);
bool ok = IntMul(&product, &a, &b);- In
Convert.c:646:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromStrRadix(&value, "_", 10);- In
Convert.c:668:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool ok = IntTryFromStrRadix(&value, "7", 10);
bool result = ok && (IntToU64(&value) == 7);- In
Convert.c:690:
DefaultAllocator alloc = DefaultAllocatorInit();
Int valid = IntInit(ALLOCATOR_OF(&alloc));
Int invalid = IntInit(ALLOCATOR_OF(&alloc));- In
Convert.c:691:
Int valid = IntInit(ALLOCATOR_OF(&alloc));
Int invalid = IntInit(ALLOCATOR_OF(&alloc));
bool ok_valid = IntTryFromStrRadix(&valid, "5", 10);- In
Convert.c:732:
Str text = StrInitFromZstr("0b101", &alloc);
Int out = IntInit(&alloc.base);
bool ok = int_try_from_binary_str(&out, &text);
bool result = ok && (IntToU64(&out) == 5u);- In
Convert.c:759:
Str text = StrInitFromZstr("0B101", &alloc);
Int out = IntInit(&alloc.base);
bool ok = int_try_from_binary_str(&out, &text);
bool result = ok && (IntToU64(&out) == 5u);- In
Convert.c:786:
Str text = StrInitFromZstr("1101", &alloc);
Int out = IntInit(&alloc.base);
bool ok = int_try_from_binary_str(&out, &text);
bool result = ok && (IntToU64(&out) == 13u);- In
Convert.c:820:
Str text = StrInitFromZstr("0o17", &alloc);
Int out = IntInit(&alloc.base);
bool ok = int_try_from_oct_str_str(&out, &text);
bool result = ok && (IntToU64(&out) == 15u);- In
Convert.c:846:
Str text = StrInitFromZstr("0O17", &alloc);
Int out = IntInit(&alloc.base);
bool ok = int_try_from_oct_str_str(&out, &text);
bool result = ok && (IntToU64(&out) == 15u);- In
Convert.c:871:
Str text = StrInitFromZstr("17", &alloc);
Int out = IntInit(&alloc.base);
bool ok = int_try_from_oct_str_str(&out, &text);
bool result = ok && (IntToU64(&out) == 15u);- In
Convert.c:958:
DefaultAllocator alloc = DefaultAllocatorInit();
Int out = IntInit(&alloc.base);
bool parsed = IntTryFromStrRadix(&out, "AZ", 36);- In
Convert.c:981:
DefaultAllocator alloc = DefaultAllocatorInit();
Int out = IntInit(&alloc.base);
bool parsed = IntTryFromStrRadix(&out, "FF", 16);- In
Convert.c:1005:
Str text = StrInitFromZstr("123", &alloc);
Int out = IntInit(&alloc.base);
bool parsed = IntTryFromStr(&out, &text);- In
Convert.c:1036:
Str text = StrInitFromZstr("+5", &alloc);
Int out = IntInit(&alloc.base);
bool parsed = IntTryFromStr(&out, &text);- In
Convert.c:1060:
Str digits = StrInitFromZstr("123", ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool ok = IntTryFromStrRadix(&value, &digits, 10);- In
Convert.c:1088:
Str digits = StrInitFromZstr("+5", ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool ok = IntTryFromStrRadix(&value, &digits, 10);- In
Convert.c:1210:
DefaultAllocator alloc = DefaultAllocatorInit();
Int out = IntInit(&alloc.base);
const char *text = "+5";- In
Convert.c:1230:
DefaultAllocator alloc = DefaultAllocatorInit();
Int out = IntInit(&alloc.base);
const char *text = "42";- In
Convert.c:1250:
DefaultAllocator alloc = DefaultAllocatorInit();
Int out = IntInit(&alloc.base);
bool ok = IntTryFromStrRadix(&out, "+5", (u8)10);- In
Convert.c:1268:
DefaultAllocator alloc = DefaultAllocatorInit();
Int out = IntInit(&alloc.base);
bool ok = IntTryFromOctStr(&out, "17");- In
Convert.c:1287:
DefaultAllocator alloc = DefaultAllocatorInit();
Int out = IntInit(&alloc.base);
bool ok = IntTryFromOctStr(&out, "017");- In
Convert.c:1374:
DefaultAllocator alloc = DefaultAllocatorInit();
Int out = IntInit(&alloc.base);
bool parsed = IntTryFromBinary(&out, "0c1");- In
Convert.c:1391:
DefaultAllocator alloc = DefaultAllocatorInit();
Int out = IntInit(&alloc.base);
bool parsed = IntTryFromBinary(&out, "0b101");- In
Convert.c:1503:
Str hex = StrInitFromZstr("ff", &alloc.base);
Int value = IntInit(&alloc.base);
bool ok = int_try_from_hex_str_str(&value, &hex);- In
Convert.c:1528:
Str hex = StrInitFromZstr("12g3", &alloc.base);
Int value = IntInit(&alloc.base);
bool ok = int_try_from_hex_str_str(&value, &hex);- In
Convert.c:1577:
u64 rem = 0;
{
Int q = IntInit(a);
rem = int_div_u64_rem(&q, &v, 1000u);
IntDeinit(&q);- In
Access.c:60:
DefaultAllocator alloc = DefaultAllocatorInit();
Int zero = IntInit(&alloc.base);
Int non_zero = IntFrom(1, &alloc.base);- In
Access.c:149:
Int value = IntFromBinary("1010000", &alloc.base);
Int zero = IntInit(&alloc.base);
bool result = IntTrailingZeroCount(&value) == 4;- In
Access.c:168:
Int power = IntFrom(1, &alloc.base);
Int other = IntFrom(24, &alloc.base);
Int zero = IntInit(&alloc.base);
IntShiftLeft(&power, 20);- In
Access.c:190:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntInit(&alloc.base);
bool error = false;- In
Access.c:357:
Int base = IntFrom(7, &alloc.base);
Int mod = IntFrom(13, &alloc.base);
Int result_value = IntInit(&alloc.base);
bool ok = IntPowMod(&result_value, &base, 20u, &mod);- In
Write.c:3820:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Int oct = IntInit(alloc_base);
Zstr z = "78";- In
Write.c:4405:
DefaultAllocator alloc = DefaultAllocatorInit();
Int v = IntInit(ALLOCATOR_OF(&alloc));
Zstr z = "9z";
StrReadFmt(z, "{}", v);- In
Write.c:4422:
DefaultAllocator alloc = DefaultAllocatorInit();
Int v = IntInit(ALLOCATOR_OF(&alloc));
Zstr z = "5";
StrReadFmt(z, "{}", v);- In
Write.c:4438:
DefaultAllocator alloc = DefaultAllocatorInit();
Int v = IntInit(ALLOCATOR_OF(&alloc));
Zstr z = "+8";
StrReadFmt(z, "{}", v);- In
Write.c:4502:
DefaultAllocator alloc = DefaultAllocatorInit();
Int v = IntInit(ALLOCATOR_OF(&alloc));
Zstr z = "ff";
StrReadFmt(z, "{x}", v);- In
Write.c:4545:
DefaultAllocator alloc = DefaultAllocatorInit();
Int v = IntInit(ALLOCATOR_OF(&alloc));
Zstr z = "101";
StrReadFmt(z, "{b}", v);- In
Write.c:4588:
DefaultAllocator alloc = DefaultAllocatorInit();
Int v = IntInit(ALLOCATOR_OF(&alloc));
Zstr z = "17";
StrReadFmt(z, "{o}", v);- In
Write.c:4603:
DefaultAllocator alloc = DefaultAllocatorInit();
Int v = IntInit(ALLOCATOR_OF(&alloc));
Zstr z = " 42";
StrReadFmt(z, "{}", v);- In
Read.c:915:
bool success = true;
Int dec = IntInit(alloc_base);
Int hex = IntInit(alloc_base);
Int bin = IntInit(alloc_base);- In
Read.c:916:
Int dec = IntInit(alloc_base);
Int hex = IntInit(alloc_base);
Int bin = IntInit(alloc_base);
Int oct = IntInit(alloc_base);- In
Read.c:917:
Int dec = IntInit(alloc_base);
Int hex = IntInit(alloc_base);
Int bin = IntInit(alloc_base);
Int oct = IntInit(alloc_base);- In
Read.c:918:
Int hex = IntInit(alloc_base);
Int bin = IntInit(alloc_base);
Int oct = IntInit(alloc_base);
Str dec_text = StrInit(&alloc);- In
Read.c:2565:
static bool test_read_int_plain(void) {
DebugAllocator dbg = DebugAllocatorInit();
Int v = IntInit(&dbg.base);
Zstr z = "12345";
StrReadFmt(z, "{}", v);- In
Read.c:2580:
static bool test_read_int_leading_plus(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Int v = IntInit(&alloc.base);
Zstr z = "+99";
StrReadFmt(z, "{}", v);- In
Read.c:2596:
static bool test_read_int_hex_plain(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Int v = IntInit(&alloc.base);
Zstr z = "ff";
StrReadFmt(z, "{x}", v);
Last updated on