Int
Description
Arbitrary-precision unsigned integer value. Int stores the magnitude as a little-endian bit-vector with no sign bit.
Fields
| Name | Description |
|---|---|
bits |
Backing bit storage for the integer magnitude. Treat as internal representation. |
Usage example (from documentation)
Int value = IntFrom(42);Usage example (Cross-references)
Usage examples (Cross-references)
- In
Io.c:27:
#endif
#if FEATURE_INT
# include <Misra/Std/Container/Int.h>
#endif
#if FEATURE_FLOAT- In
Io.c:2978:
#if FEATURE_INT
bool _write_Int(Str *o, FmtInfo *fmt_info, Int *value) {
if (!o || !fmt_info || !value) {
LOG_FATAL("Invalid arguments");- In
Io.c:2997:
if (!buffer) {
LOG_ERROR("Failed to allocate buffer for Int character formatting");
return false;
}- In
Io.c:3175:
#if FEATURE_INT
Zstr _read_Int(Zstr i, FmtInfo *fmt_info, Int *value) {
if (!i || !value) {
LOG_FATAL("Invalid arguments");- In
Io.c:3181:
if (fmt_info && (fmt_info->flags & FMT_FLAG_CHAR)) {
LOG_ERROR("Character-format reads are not supported for Int");
return i;
}- In
Io.c:3195:
if (!StrIterRemainingLength(&si)) {
LOG_ERROR("Failed to parse Int: empty input");
return StrIterDataAt(&si, StrIterIndex(&si));
}- In
Io.c:3217:
if (radix == 16 && p0 == '0' && (p1 == 'x' || p1 == 'X')) {
LOG_ERROR("Int hex reads expect plain hex digits without a 0x prefix");
return start;
}- In
Io.c:3221:
}
if (radix == 2 && p0 == '0' && (p1 == 'b' || p1 == 'B')) {
LOG_ERROR("Int binary reads expect plain binary digits without a 0b prefix");
return start;
}- In
Io.c:3225:
}
if (radix == 8 && p0 == '0' && (p1 == 'o' || p1 == 'O')) {
LOG_ERROR("Int octal reads expect plain octal digits without a 0o prefix");
return start;
}- In
Io.c:3234:
if (StrIterIndex(&si) == StrIterIndex(&digits_saved)) {
LOG_ERROR("Failed to parse Int");
return start;
}- In
Io.c:3240:
char trailing = 0;
if (StrIterPeek(&si, &trailing) && trailing == '_') {
LOG_ERROR("Int reads do not accept digit separators");
return start;
}- In
Io.c:3245:
Str temp = StrInitFromCstr(start, StrIterIndex(&si) - StrIterIndex(&saved), IntAllocator(value));
Int parsed = IntInit(IntAllocator(value));
bool ok = IntTryFromStrRadix(&parsed, StrBegin(&temp), radix);- In
Float.c:10:
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Container/Float/Private.h>
#include <Misra/Std/Container/Int.h>
#include <Misra/Std/Log.h>- In
Float.c:18:
static bool float_try_from_u64_value(Float *out, u64 value, Allocator *alloc);
static bool float_try_from_i64_value(Float *out, i64 value, Allocator *alloc);
static bool float_try_from_int_value(Float *out, const Int *value);
static bool float_try_from_f32_value(Float *out, float value, Allocator *alloc);
static bool float_try_from_f64_value(Float *out, double value, Allocator *alloc);- In
Float.c:21:
static bool float_try_from_f32_value(Float *out, float value, Allocator *alloc);
static bool float_try_from_f64_value(Float *out, double value, Allocator *alloc);
static bool float_pow10(Int *out, u64 power, Allocator *alloc);
static bool float_scale_to_exponent(Float *value, i64 target_exponent);
static bool float_try_abs_compare(int *out, const Float *lhs, const Float *rhs);- 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:161:
}
static bool float_pow10(Int *out, u64 power, Allocator *alloc) {
Int base;
Int result;- In
Float.c:162:
static bool float_pow10(Int *out, u64 power, Allocator *alloc) {
Int base;
Int result;- In
Float.c:163:
static bool float_pow10(Int *out, u64 power, Allocator *alloc) {
Int base;
Int result;
if (!out) {- 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:260:
while (int_mod_u64(&value->significand, 10) == 0) {
Int quotient = IntInit(FloatAllocator(value));
(void)int_div_u64_rem("ient, &value->significand, 10);- In
Float.c:347:
}
static bool float_try_from_int_value(Float *out, const Int *value) {
if (!out || !value) {
LOG_FATAL("Invalid arguments");- In
Float.c:380:
}
Float float_from_int(const Int *value, Allocator *alloc) {
Float result;- In
Float.c:405:
}
bool FloatToInt(Int *result, const Float *value) {
ValidateInt(result);
ValidateFloat(value);- In
Float.c:409:
ValidateFloat(value);
Int temp = IntInit(IntAllocator(result));
if (FloatIsNegative(value)) {- In
Float.c:423:
if (value->exponent >= 0) {
Int factor = IntInit(FloatAllocator(value));
if (!IntTryClone(&temp, &value->significand) ||- In
Float.c:440:
{
u64 places = (u64)(-value->exponent);
Int factor = IntInit(FloatAllocator(value));
bool ok = false;- In
Float.c:755:
}
int float_compare_int_with_error(const Float *lhs, const Int *rhs, bool *error) {
Float rhs_value = FloatInit(FloatAllocator(lhs));
int cmp = 0;- In
Float.c:777:
}
int float_compare_int(const Float *lhs, const Int *rhs) {
return float_compare_int_with_error(lhs, rhs, NULL);
}- In
Float.c:963:
}
bool float_add_int(Float *result, const Float *a, const Int *b) {
Float rhs = FloatInit(FloatAllocator(result));- In
Float.c:1034:
}
bool float_sub_int(Float *result, const Float *a, const Int *b) {
Float rhs = FloatInit(FloatAllocator(result));- In
Float.c:1108:
}
bool float_mul_int(Float *result, const Float *a, const Int *b) {
Float rhs = FloatInit(FloatAllocator(result));- In
Float.c:1165:
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:1166:
Float temp = FloatInit(FloatAllocator(result));
Int scale = IntInit(FloatAllocator(result));
Int scaled = IntInit(FloatAllocator(result));
ValidateFloat(result);- In
Float.c:1208:
}
bool float_div_int(Float *result, const Float *a, const Int *b, u64 precision) {
Float rhs = FloatInit(FloatAllocator(result));
bool ok = false;- In
Int.c:7:
/// Arbitrary-precision unsigned integer implementation built on top of BitVec.
#include <Misra/Std/Container/Int.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Container/Int/Private.h>- In
Int.c:9:
#include <Misra/Std/Container/Int.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Container/Int/Private.h>
#include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Log.h>- In
Int.c:15:
typedef struct {
bool negative;
Int magnitude;
} SignedInt;- In
Int.c:20:
#define INT_BITS(value) (&(value)->bits)
static void int_normalize(Int *value);
static bool int_validate_radix(u8 radix);
static bool int_try_from_str_radix_impl(Int *out, Zstr digits, u64 length, u64 start, u8 radix, bool allow_underscores);- In
Int.c:22:
static void int_normalize(Int *value);
static bool int_validate_radix(u8 radix);
static bool int_try_from_str_radix_impl(Int *out, Zstr digits, u64 length, u64 start, u8 radix, bool allow_underscores);
static bool int_try_init_with_capacity(Int *out, u64 capacity, Allocator *alloc);
static bool int_try_from_i64_with_allocator(Int *out, i64 value, Allocator *alloc);- In
Int.c:23:
static bool int_validate_radix(u8 radix);
static bool int_try_from_str_radix_impl(Int *out, Zstr digits, u64 length, u64 start, u8 radix, bool allow_underscores);
static bool int_try_init_with_capacity(Int *out, u64 capacity, Allocator *alloc);
static bool int_try_from_i64_with_allocator(Int *out, i64 value, Allocator *alloc);
static bool int_try_clone_value(Int *out, const Int *value);- In
Int.c:24:
static bool int_try_from_str_radix_impl(Int *out, Zstr digits, u64 length, u64 start, u8 radix, bool allow_underscores);
static bool int_try_init_with_capacity(Int *out, u64 capacity, Allocator *alloc);
static bool int_try_from_i64_with_allocator(Int *out, i64 value, Allocator *alloc);
static bool int_try_clone_value(Int *out, const Int *value);
static u64 int_u64_bits(u64 value);- In
Int.c:25:
static bool int_try_init_with_capacity(Int *out, u64 capacity, Allocator *alloc);
static bool int_try_from_i64_with_allocator(Int *out, i64 value, Allocator *alloc);
static bool int_try_clone_value(Int *out, const Int *value);
static u64 int_u64_bits(u64 value);- In
Int.c:28:
static u64 int_u64_bits(u64 value);
static Int int_wrap(BitVec bits) {
Int value;- In
Int.c:29:
static Int int_wrap(BitVec bits) {
Int value;
value.bits = bits;- In
Int.c:35:
}
static bool int_try_init_with_capacity(Int *out, u64 capacity, Allocator *alloc) {
if (!out) {
LOG_FATAL("Invalid arguments");- In
Int.c:50:
}
bool int_try_from_u64(Int *out, u64 value, Allocator *alloc) {
u64 bits = int_u64_bits(value);- In
Int.c:71:
}
static bool int_try_from_i64_with_allocator(Int *out, i64 value, Allocator *alloc) {
if (value < 0) {
LOG_ERROR("Int cannot represent negative values");- In
Int.c:73:
static bool int_try_from_i64_with_allocator(Int *out, i64 value, Allocator *alloc) {
if (value < 0) {
LOG_ERROR("Int cannot represent negative values");
return false;
}- In
Int.c:80:
}
static u64 int_significant_bits(const Int *value) {
ValidateInt(value);- In
Int.c:111:
}
static void int_replace(Int *dst, Int *src) {
IntDeinit(dst);
*dst = *src;- In
Int.c:116:
}
static void int_swap(Int *a, Int *b) {
Int tmp = *a;
*a = *b;- In
Int.c:117:
static void int_swap(Int *a, Int *b) {
Int tmp = *a;
*a = *b;
*b = tmp;- In
Int.c:204:
}
static bool sint_mul_unsigned(SignedInt *result, SignedInt *a, Int *b) {
SignedInt temp = sint_init(IntAllocator(&result->magnitude));- In
Int.c:217:
}
static void int_normalize(Int *value) {
ValidateInt(value);
BitVecResize(INT_BITS(value), int_significant_bits(value));- In
Int.c:222:
}
static bool int_is_odd(const Int *value) {
ValidateInt(value);
return BitVecLen(INT_BITS(value)) > 0 && BitVecGet(INT_BITS(value), 0);- In
Int.c:227:
}
static bool int_is_one(const Int *value) {
ValidateInt(value);
return IntBitLength(value) == 1 && BitVecGet(INT_BITS(value), 0);- In
Int.c:232:
}
static bool int_mul_u64_in_place(Int *value, u64 factor) {
Int lhs;
Int rhs;- In
Int.c:233:
static bool int_mul_u64_in_place(Int *value, u64 factor) {
Int lhs;
Int rhs;
Int result = IntInit(IntAllocator(value));- In
Int.c:234:
static bool int_mul_u64_in_place(Int *value, u64 factor) {
Int lhs;
Int rhs;
Int result = IntInit(IntAllocator(value));- In
Int.c:235:
Int lhs;
Int rhs;
Int result = IntInit(IntAllocator(value));
if (!int_try_clone_value(&lhs, value)) {- In
Int.c:257:
}
static bool int_add_u64_in_place(Int *value, u64 addend) {
Int lhs;
Int rhs;- In
Int.c:258:
static bool int_add_u64_in_place(Int *value, u64 addend) {
Int lhs;
Int rhs;
Int result = IntInit(IntAllocator(value));- In
Int.c:259:
static bool int_add_u64_in_place(Int *value, u64 addend) {
Int lhs;
Int rhs;
Int result = IntInit(IntAllocator(value));- In
Int.c:260:
Int lhs;
Int rhs;
Int result = IntInit(IntAllocator(value));
if (!int_try_clone_value(&lhs, value)) {- In
Int.c:317:
static bool
int_try_from_str_radix_impl(Int *out, Zstr digits, u64 length, u64 start, u8 radix, bool allow_underscores) {
Int result;
bool saw_digit = false;- In
Int.c:318:
static bool
int_try_from_str_radix_impl(Int *out, Zstr digits, u64 length, u64 start, u8 radix, bool allow_underscores) {
Int result;
bool saw_digit = false;- In
Int.c:341:
digit = int_radix_digit(digits[i]);
if (digit < 0 || digit >= radix) {
LOG_ERROR("Invalid digit for radix in Int conversion");
IntDeinit(&result);
return false;- In
Int.c:365:
}
u64 IntBitLength(const Int *value) {
return int_significant_bits(value);
}- In
Int.c:369:
}
u64 IntByteLength(const Int *value) {
u64 bits = IntBitLength(value);
return bits == 0 ? 0 : CEIL_DIV(bits, 8u);- In
Int.c:374:
}
bool IntTryLog2(const Int *value, u64 *out) {
if (!value || !out) {
LOG_FATAL("Invalid arguments");- In
Int.c:390:
}
u64 IntLog2WithError(const Int *value, bool *error) {
u64 out = 0;
bool ok = IntTryLog2(value, &out);- In
Int.c:401:
}
u64 IntTrailingZeroCount(const Int *value) {
ValidateInt(value);- In
Int.c:413:
}
bool IntIsZero(const Int *value) {
return IntBitLength(value) == 0;
}- In
Int.c:417:
}
bool IntIsOne(const Int *value) {
return int_is_one(value);
}- In
Int.c:421:
}
bool IntIsEven(const Int *value) {
ValidateInt(value);
return !int_is_odd(value);- In
Int.c:426:
}
bool IntIsOdd(const Int *value) {
return int_is_odd(value);
}- In
Int.c:430:
}
bool IntFitsU64(const Int *value) {
ValidateInt(value);
return IntBitLength(value) <= 64;- In
Int.c:435:
}
bool IntIsPowerOfTwo(const Int *value) {
ValidateInt(value);- In
Int.c:441:
}
static bool int_try_clone_value(Int *out, const Int *value) {
if (!out || !value) {
LOG_FATAL("Invalid arguments");- In
Int.c:456:
}
bool IntTryClone(Int *out, const Int *value) {
return int_try_clone_value(out, value);
}- In
Int.c:460:
}
Int IntClone(const Int *value) {
Int clone;- In
Int.c:461:
Int IntClone(const Int *value) {
Int clone;
ValidateInt(value);- In
Int.c:469:
}
Int int_from_u64(u64 value, Allocator *alloc) {
Int result = IntInit(alloc);- In
Int.c:470:
Int int_from_u64(u64 value, Allocator *alloc) {
Int result = IntInit(alloc);
(void)int_try_from_u64(&result, value, alloc);- In
Int.c:476:
}
Int int_from_i64(i64 value, Allocator *alloc) {
if (value < 0) {
LOG_FATAL("Int cannot represent negative values");- In
Int.c:478:
Int int_from_i64(i64 value, Allocator *alloc) {
if (value < 0) {
LOG_FATAL("Int cannot represent negative values");
}- In
Int.c:484:
}
bool IntTryToU64(const Int *value, u64 *out) {
if (!value || !out) {
LOG_FATAL("Invalid arguments");- In
Int.c:492:
if (!IntFitsU64(value)) {
LOG_ERROR("Int value exceeds u64 range");
return false;
}- In
Int.c:500:
}
u64 IntToU64WithError(const Int *value, bool *error) {
u64 out = 0;
bool ok = IntTryToU64(value, &out);- In
Int.c:511:
}
Int int_from_bytes_le(const u8 *bytes, u64 len, Allocator *alloc) {
if (!bytes && len != 0) {
LOG_FATAL("bytes is NULL");- In
Int.c:516:
}
Int result = IntInit(alloc);
if (len == 0) {- In
Int.c:530:
}
u64 IntToBytesLE(const Int *value, u8 *bytes, u64 max_len) {
ValidateInt(value);- In
Int.c:566:
}
Int int_from_bytes_be(const u8 *bytes, u64 len, Allocator *alloc) {
if (!bytes && len != 0) {
LOG_FATAL("bytes is NULL");- In
Int.c:571:
}
Int result = IntInit(alloc);
for (u64 i = 0; i < len; i++) {- In
Int.c:584:
}
u64 IntToBytesBE(const Int *value, u8 *bytes, u64 max_len) {
ValidateInt(value);- In
Int.c:620:
}
bool int_try_from_str_zstr(Int *out, Zstr decimal) {
u64 start = 0;
u64 len = 0;- In
Int.c:636:
}
bool int_try_from_str_str(Int *out, const Str *decimal) {
u64 start = 0;- In
Int.c:650:
}
Int int_from_str_zstr(Zstr decimal, Allocator *alloc) {
Int out = IntInit(alloc);- In
Int.c:651:
Int int_from_str_zstr(Zstr decimal, Allocator *alloc) {
Int out = IntInit(alloc);
(void)int_try_from_str_zstr(&out, decimal);- In
Int.c:657:
}
Int int_from_str_str(const Str *decimal, Allocator *alloc) {
Int out = IntInit(alloc);- In
Int.c:658:
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:664:
}
bool int_try_to_str(Str *out, const Int *value, Allocator *alloc) {
return int_try_to_str_radix(out, value, 10, false, alloc);
}- In
Int.c:668:
}
Str int_to_str(const Int *value, Allocator *alloc) {
Str result;- In
Int.c:680:
}
bool int_try_from_str_radix_zstr(Int *out, Zstr digits, u8 radix) {
u64 start = 0;
u64 len = 0;- In
Int.c:695:
}
bool int_try_from_str_radix_str(Int *out, const Str *digits, u8 radix) {
u64 start = 0;- In
Int.c:708:
}
Int int_from_str_radix_zstr(Zstr digits, u8 radix, Allocator *alloc) {
Int out = IntInit(alloc);- In
Int.c:709:
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:715:
}
Int int_from_str_radix_str(const Str *digits, u8 radix, Allocator *alloc) {
Int out = IntInit(alloc);- In
Int.c:716:
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:722:
}
bool int_try_to_str_radix(Str *out, const Int *value, u8 radix, bool uppercase, Allocator *alloc) {
Int current;
Str result;- In
Int.c:723:
bool int_try_to_str_radix(Str *out, const Int *value, u8 radix, bool uppercase, Allocator *alloc) {
Int current;
Str result;- In
Int.c:749:
while (!IntIsZero(¤t)) {
Int quotient = IntInit(alloc);
u64 digit = 0;- In
Int.c:777:
}
Str int_to_str_radix(const Int *value, u8 radix, bool uppercase, Allocator *alloc) {
Str result;- In
Int.c:789:
}
bool int_try_from_binary_zstr(Int *out, Zstr binary) {
u64 start = 0;
u64 len = 0;- In
Int.c:805:
}
bool int_try_from_binary_str(Int *out, const Str *binary) {
u64 start = 0;- In
Int.c:820:
}
Int int_from_binary_zstr(Zstr binary, Allocator *alloc) {
Int out = IntInit(alloc);- In
Int.c:821:
Int int_from_binary_zstr(Zstr binary, Allocator *alloc) {
Int out = IntInit(alloc);
(void)int_try_from_binary_zstr(&out, binary);- In
Int.c:827:
}
Int int_from_binary_str(const Str *binary, Allocator *alloc) {
Int out = IntInit(alloc);- In
Int.c:828:
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:834:
}
Str IntToBinary(const Int *value) {
return IntToStrRadix(value, 2, false);
}- In
Int.c:838:
}
bool int_try_from_oct_str_zstr(Int *out, Zstr octal) {
u64 start = 0;
u64 len = 0;- In
Int.c:854:
}
bool int_try_from_oct_str_str(Int *out, const Str *octal) {
u64 start = 0;- In
Int.c:869:
}
Int int_from_oct_str_zstr(Zstr octal, Allocator *alloc) {
Int out = IntInit(alloc);- In
Int.c:870:
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:876:
}
Int int_from_oct_str_str(const Str *octal, Allocator *alloc) {
Int out = IntInit(alloc);- In
Int.c:877:
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:883:
}
Str IntToOctStr(const Int *value) {
return IntToStrRadix(value, 8, false);
}- In
Int.c:887:
}
bool int_try_from_hex_str_zstr(Int *out, Zstr hex) {
u64 len = 0;- In
Int.c:898:
}
bool int_try_from_hex_str_str(Int *out, const Str *hex) {
if (!out || !hex) {
LOG_FATAL("Invalid arguments");- In
Int.c:906:
}
Int int_from_hex_str_zstr(Zstr hex, Allocator *alloc) {
Int out = IntInit(alloc);- In
Int.c:907:
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:913:
}
Int int_from_hex_str_str(const Str *hex, Allocator *alloc) {
Int out = IntInit(alloc);- In
Int.c:914:
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:920:
}
Str IntToHexStr(const Int *value) {
return IntToStrRadix(value, 16, false);
}- In
Int.c:927:
// design, so there's no sign byte to mix in.
u64 int_hash(const void *data, u32 size) {
const Int *value = (const Int *)data;
u64 hash = 1469598103934665603ULL;- In
Int.c:944:
i32 int_compare(const void *lhs, const void *rhs) {
const Int *a = (const Int *)lhs;
const Int *b = (const Int *)rhs;- In
Int.c:945:
i32 int_compare(const void *lhs, const void *rhs) {
const Int *a = (const Int *)lhs;
const Int *b = (const Int *)rhs;
ValidateInt(a);- In
Int.c:972:
}
int int_compare_u64(const Int *lhs, u64 rhs) {
ValidateInt(lhs);- In
Int.c:993:
}
int int_compare_i64(const Int *lhs, i64 rhs) {
ValidateInt(lhs);- In
Int.c:1003:
}
bool IntShiftLeft(Int *value, u64 positions) {
ValidateInt(value);- In
Int.c:1031:
}
bool IntShiftRight(Int *value, u64 positions) {
ValidateInt(value);- In
Int.c:1055:
}
bool int_add(Int *result, const Int *a, const Int *b) {
ValidateInt(result);
ValidateInt(a);- In
Int.c:1063:
u64 b_bits = IntBitLength(b);
u64 max_bits = MAX2(a_bits, b_bits);
Int temp;
bool carry = false;- In
Int.c:1100:
}
bool int_add_u64(Int *result, const Int *value, u64 addend) {
ValidateInt(result);
ValidateInt(value);- In
Int.c:1104:
ValidateInt(value);
Int temp;
if (!int_try_clone_value(&temp, value)) {- In
Int.c:1117:
}
bool int_add_i64(Int *result, const Int *value, i64 addend) {
u64 magnitude = int_i64_magnitude(addend);- In
Int.c:1134:
}
bool int_sub(Int *result, const Int *a, const Int *b) {
ValidateInt(result);
ValidateInt(a);- In
Int.c:1145:
u64 a_bits = IntBitLength(a);
u64 b_bits = IntBitLength(b);
Int temp;
bool borrow = false;- In
Int.c:1176:
}
bool int_sub_u64(Int *result, const Int *value, u64 subtrahend) {
ValidateInt(result);
ValidateInt(value);- In
Int.c:1180:
ValidateInt(value);
Int rhs;
bool ok = false;- In
Int.c:1191:
}
bool int_sub_i64(Int *result, const Int *value, i64 subtrahend) {
u64 magnitude = int_i64_magnitude(subtrahend);- In
Int.c:1204:
}
bool int_mul(Int *result, const Int *a, const Int *b) {
ValidateInt(result);
ValidateInt(a);- In
Int.c:1210:
u64 b_bits = IntBitLength(b);
Int acc = IntInit(IntAllocator(result));
if (IntIsZero(a) || IntIsZero(b)) {- In
Int.c:1223:
}
Int partial;
Int next = IntInit(IntAllocator(result));- In
Int.c:1224:
Int partial;
Int next = IntInit(IntAllocator(result));
if (!int_try_clone_value(&partial, a)) {- In
Int.c:1250:
}
bool int_mul_u64(Int *result, const Int *value, u64 factor) {
ValidateInt(result);
ValidateInt(value);- In
Int.c:1254:
ValidateInt(value);
Int temp;
if (!int_try_clone_value(&temp, value)) {- In
Int.c:1267:
}
bool int_mul_i64(Int *result, const Int *value, i64 factor) {
if (factor < 0) {
LOG_FATAL("Int cannot be multiplied by a negative scalar");- In
Int.c:1269:
bool int_mul_i64(Int *result, const Int *value, i64 factor) {
if (factor < 0) {
LOG_FATAL("Int cannot be multiplied by a negative scalar");
}- In
Int.c:1275:
}
bool IntSquare(Int *result, const Int *value) {
return int_mul(result, value, value);
}- In
Int.c:1279:
}
bool int_pow(Int *result, const Int *base, const Int *exponent) {
ValidateInt(result);
ValidateInt(base);- In
Int.c:1285:
if (!IntFitsU64(exponent)) {
LOG_ERROR("Int exponent exceeds u64 range");
return false;
}- In
Int.c:1292:
}
bool int_pow_u64(Int *result, const Int *base, u64 exponent) {
ValidateInt(result);
ValidateInt(base);- In
Int.c:1296:
ValidateInt(base);
Int acc;
Int current;- In
Int.c:1297:
Int acc;
Int current;
if (!int_try_from_u64(&acc, 1, IntAllocator(result))) {- In
Int.c:1309:
while (exponent > 0) {
if (exponent & 1u) {
Int next = IntInit(IntAllocator(result));
if (!int_mul(&next, &acc, ¤t)) {- In
Int.c:1323:
exponent >>= 1u;
if (exponent > 0) {
Int next = IntInit(IntAllocator(result));
if (!IntSquare(&next, ¤t)) {- In
Int.c:1341:
}
bool int_pow_i64(Int *result, const Int *base, i64 exponent) {
if (exponent < 0) {
LOG_FATAL("Int exponent cannot be negative");- In
Int.c:1343:
bool int_pow_i64(Int *result, const Int *base, i64 exponent) {
if (exponent < 0) {
LOG_FATAL("Int exponent cannot be negative");
}- In
Int.c:1349:
}
bool int_div_mod(Int *quotient, Int *remainder, const Int *dividend, const Int *divisor) {
ValidateInt(quotient);
ValidateInt(remainder);- In
Int.c:1363:
}
Int normalized_dividend = IntInit(IntAllocator(quotient));
Int normalized_divisor = IntInit(IntAllocator(quotient));
Int q = IntInit(IntAllocator(quotient));- In
Int.c:1364:
Int normalized_dividend = IntInit(IntAllocator(quotient));
Int normalized_divisor = IntInit(IntAllocator(quotient));
Int q = IntInit(IntAllocator(quotient));
Int r = IntInit(IntAllocator(remainder));- In
Int.c:1365:
Int normalized_dividend = IntInit(IntAllocator(quotient));
Int normalized_divisor = IntInit(IntAllocator(quotient));
Int q = IntInit(IntAllocator(quotient));
Int r = IntInit(IntAllocator(remainder));
bool ok = false;- In
Int.c:1366:
Int normalized_divisor = IntInit(IntAllocator(quotient));
Int q = IntInit(IntAllocator(quotient));
Int r = IntInit(IntAllocator(remainder));
bool ok = false;- In
Int.c:1385:
for (u64 shift = dividend_bits - divisor_bits + 1; shift > 0; shift--) {
u64 bit = shift - 1;
Int shifted = IntInit(IntAllocator(quotient));
if (!int_try_clone_value(&shifted, &normalized_divisor) || !IntShiftLeft(&shifted, bit)) {- In
Int.c:1393:
if (IntGE(&r, &shifted)) {
Int next = IntInit(IntAllocator(quotient));
if (!int_sub(&next, &r, &shifted)) {- In
Int.c:1435:
}
bool int_div(Int *result, const Int *dividend, const Int *divisor) {
Int quotient = IntInit(IntAllocator(result));
Int remainder = IntInit(IntAllocator(result));- In
Int.c:1436:
bool int_div(Int *result, const Int *dividend, const Int *divisor) {
Int quotient = IntInit(IntAllocator(result));
Int remainder = IntInit(IntAllocator(result));- In
Int.c:1437:
bool int_div(Int *result, const Int *dividend, const Int *divisor) {
Int quotient = IntInit(IntAllocator(result));
Int remainder = IntInit(IntAllocator(result));
if (!int_div_mod("ient, &remainder, dividend, divisor)) {- In
Int.c:1450:
}
bool int_div_exact(Int *result, const Int *dividend, const Int *divisor) {
ValidateInt(result);
ValidateInt(dividend);- In
Int.c:1460:
}
Int quotient = IntInit(IntAllocator(result));
Int remainder = IntInit(IntAllocator(result));- In
Int.c:1461:
Int quotient = IntInit(IntAllocator(result));
Int remainder = IntInit(IntAllocator(result));
if (!int_div_mod("ient, &remainder, dividend, divisor)) {- In
Int.c:1479:
}
bool int_div_u64(Int *result, const Int *dividend, u64 divisor) {
Int divisor_value = IntInit(IntAllocator(dividend));- In
Int.c:1480:
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:1492:
}
bool int_div_i64(Int *result, const Int *dividend, i64 divisor) {
Int divisor_value = IntInit(IntAllocator(dividend));- In
Int.c:1493:
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:1505:
}
bool int_div_exact_u64(Int *result, const Int *dividend, u64 divisor) {
Int divisor_value = IntInit(IntAllocator(dividend));- In
Int.c:1506:
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:1518:
}
bool int_div_exact_i64(Int *result, const Int *dividend, i64 divisor) {
Int divisor_value = IntInit(IntAllocator(dividend));- In
Int.c:1519:
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:1531:
}
bool int_div_mod_u64(Int *quotient, Int *remainder, const Int *dividend, u64 divisor) {
Int divisor_value = IntInit(IntAllocator(dividend));- In
Int.c:1532:
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:1544:
}
bool int_div_mod_i64(Int *quotient, Int *remainder, const Int *dividend, i64 divisor) {
Int divisor_value = IntInit(IntAllocator(dividend));- In
Int.c:1545:
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:1557:
}
u64 int_div_u64_rem(Int *quotient, const Int *dividend, u64 divisor) {
ValidateInt(quotient);
ValidateInt(dividend);- In
Int.c:1566:
}
Int divisor_value = IntInit(IntAllocator(dividend));
Int remainder = IntInit(IntAllocator(quotient));
u64 rem = 0;- In
Int.c:1567:
Int divisor_value = IntInit(IntAllocator(dividend));
Int remainder = IntInit(IntAllocator(quotient));
u64 rem = 0;- In
Int.c:1588:
}
bool int_mod(Int *result, const Int *dividend, const Int *divisor) {
Int quotient = IntInit(IntAllocator(result));
Int remainder = IntInit(IntAllocator(result));- In
Int.c:1589:
bool int_mod(Int *result, const Int *dividend, const Int *divisor) {
Int quotient = IntInit(IntAllocator(result));
Int remainder = IntInit(IntAllocator(result));- In
Int.c:1590:
bool int_mod(Int *result, const Int *dividend, const Int *divisor) {
Int quotient = IntInit(IntAllocator(result));
Int remainder = IntInit(IntAllocator(result));
if (!int_div_mod("ient, &remainder, dividend, divisor)) {- In
Int.c:1603:
}
bool int_mod_u64_into(Int *result, const Int *dividend, u64 divisor) {
Int quotient = IntInit(IntAllocator(result));- In
Int.c:1604:
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:1611:
}
bool int_mod_i64_into(Int *result, const Int *dividend, i64 divisor) {
Int quotient = IntInit(IntAllocator(result));- In
Int.c:1612:
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:1619:
}
u64 int_mod_u64(const Int *value, u64 modulus) {
ValidateInt(value);- In
Int.c:1627:
}
Int quotient = IntInit(IntAllocator(value));
u64 rem = int_div_u64_rem("ient, value, modulus);- In
Int.c:1634:
}
bool IntGCD(Int *result, const Int *a, const Int *b) {
ValidateInt(result);
ValidateInt(a);- In
Int.c:1639:
ValidateInt(b);
Int x = IntInit(IntAllocator(a));
Int y = IntInit(IntAllocator(b));- In
Int.c:1640:
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:1649:
while (!IntIsZero(&y)) {
Int r = IntInit(IntAllocator(result));
if (!int_mod(&r, &x, &y)) {- In
Int.c:1667:
}
bool IntLCM(Int *result, const Int *a, const Int *b) {
ValidateInt(result);
ValidateInt(a);- In
Int.c:1673:
if (IntIsZero(a) || IntIsZero(b)) {
Int zero = IntInit(IntAllocator(result));
int_replace(result, &zero);
return true;- In
Int.c:1678:
}
Int gcd = IntInit(IntAllocator(result));
Int quotient = IntInit(IntAllocator(result));
Int lcm = IntInit(IntAllocator(result));- In
Int.c:1679:
Int gcd = IntInit(IntAllocator(result));
Int quotient = IntInit(IntAllocator(result));
Int lcm = IntInit(IntAllocator(result));- In
Int.c:1680:
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:1695:
}
bool IntRootRem(Int *root, Int *remainder, const Int *value, u64 degree) {
ValidateInt(root);
ValidateInt(remainder);- In
Int.c:1709:
if (IntIsZero(value)) {
Int zero_root = IntInit(IntAllocator(root));
Int zero_rem = IntInit(IntAllocator(remainder));- In
Int.c:1710:
if (IntIsZero(value)) {
Int zero_root = IntInit(IntAllocator(root));
Int zero_rem = IntInit(IntAllocator(remainder));
int_replace(root, &zero_root);- In
Int.c:1717:
}
if (degree == 1) {
Int exact_root = IntInit(IntAllocator(root));
Int zero_rem = IntInit(IntAllocator(remainder));- In
Int.c:1718:
if (degree == 1) {
Int exact_root = IntInit(IntAllocator(root));
Int zero_rem = IntInit(IntAllocator(remainder));
if (!IntTryClone(&exact_root, value)) {- In
Int.c:1732:
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:1733:
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:1734:
Int low = IntInit(IntAllocator(root));
Int high = IntInit(IntAllocator(root));
Int best = IntInit(IntAllocator(root));
Int one = IntInit(IntAllocator(root));- In
Int.c:1735:
Int high = IntInit(IntAllocator(root));
Int best = IntInit(IntAllocator(root));
Int one = IntInit(IntAllocator(root));
if ((bits % degree) != 0) {- In
Int.c:1761:
while (IntLE(&low, &high)) {
Int sum = IntInit(IntAllocator(root));
Int mid = IntInit(IntAllocator(root));
Int mid_pow = IntInit(IntAllocator(root));- In
Int.c:1762:
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:1763:
Int sum = IntInit(IntAllocator(root));
Int mid = IntInit(IntAllocator(root));
Int mid_pow = IntInit(IntAllocator(root));
int cmp = 0;- In
Int.c:1790:
if (cmp <= 0) {
Int next = IntInit(IntAllocator(root));
IntDeinit(&best);- In
Int.c:1816:
low = next;
} else {
Int next = IntInit(IntAllocator(root));
if (IntEQ(&mid, &one) || IntIsZero(&mid)) {- In
Int.c:1842:
{
Int power = IntInit(IntAllocator(root));
Int rem = IntInit(IntAllocator(remainder));- In
Int.c:1843:
{
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:1867:
}
bool IntRoot(Int *result, const Int *value, u64 degree) {
Int root = IntInit(IntAllocator(result));
Int remainder = IntInit(IntAllocator(result));- In
Int.c:1868:
bool IntRoot(Int *result, const Int *value, u64 degree) {
Int root = IntInit(IntAllocator(result));
Int remainder = IntInit(IntAllocator(result));- In
Int.c:1869:
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:1882:
}
bool IntSqrtRem(Int *root, Int *remainder, const Int *value) {
return IntRootRem(root, remainder, value, 2);
}- In
Int.c:1886:
}
bool IntSqrt(Int *result, const Int *value) {
return IntRoot(result, value, 2);
}- In
Int.c:1890:
}
bool IntIsPerfectSquare(const Int *value) {
ValidateInt(value);- In
Int.c:1893:
ValidateInt(value);
Int root = IntInit(IntAllocator(value));
Int remainder = IntInit(IntAllocator(value));
bool result = false;- In
Int.c:1894:
Int root = IntInit(IntAllocator(value));
Int remainder = IntInit(IntAllocator(value));
bool result = false;- In
Int.c:1909:
}
bool IntIsPerfectPower(const Int *value) {
ValidateInt(value);- In
Int.c:1923:
for (u64 degree = 2; degree <= max_degree; degree++) {
Int root = IntInit(IntAllocator(value));
Int remainder = IntInit(IntAllocator(value));
bool exact = false;- In
Int.c:1924:
for (u64 degree = 2; degree <= max_degree; degree++) {
Int root = IntInit(IntAllocator(value));
Int remainder = IntInit(IntAllocator(value));
bool exact = false;- In
Int.c:1945:
}
bool IntTryJacobi(int *out, const Int *a, const Int *n) {
ValidateInt(a);
ValidateInt(n);- In
Int.c:1958:
}
Int aa = IntInit(IntAllocator(a));
Int nn = IntInit(IntAllocator(n));
int result = 1;- In
Int.c:1959:
Int aa = IntInit(IntAllocator(a));
Int nn = IntInit(IntAllocator(n));
int result = 1;- In
Int.c:2008:
}
int IntJacobiWithError(const Int *a, const Int *n, bool *error) {
int out = 0;
bool ok = IntTryJacobi(&out, a, n);- In
Int.c:2019:
}
bool IntModAdd(Int *result, const Int *a, const Int *b, const Int *modulus) {
ValidateInt(result);
ValidateInt(a);- In
Int.c:2030:
}
Int ar = IntInit(IntAllocator(result));
Int br = IntInit(IntAllocator(result));
Int sum = IntInit(IntAllocator(result));- In
Int.c:2031:
Int ar = IntInit(IntAllocator(result));
Int br = IntInit(IntAllocator(result));
Int sum = IntInit(IntAllocator(result));- In
Int.c:2032:
Int ar = IntInit(IntAllocator(result));
Int br = IntInit(IntAllocator(result));
Int sum = IntInit(IntAllocator(result));
if (!int_mod(&ar, a, modulus) || !int_mod(&br, b, modulus) || !int_add(&sum, &ar, &br) ||- In
Int.c:2048:
}
bool IntModSub(Int *result, const Int *a, const Int *b, const Int *modulus) {
ValidateInt(result);
ValidateInt(a);- In
Int.c:2059:
}
Int ar = IntInit(IntAllocator(result));
Int br = IntInit(IntAllocator(result));- In
Int.c:2060:
Int ar = IntInit(IntAllocator(result));
Int br = IntInit(IntAllocator(result));
if (!int_mod(&ar, a, modulus) || !int_mod(&br, b, modulus)) {- In
Int.c:2075:
}
} else {
Int diff = IntInit(IntAllocator(result));
if (!int_sub(&diff, &br, &ar)) {- In
Int.c:2084:
}
if (IntIsZero(&diff)) {
Int zero = IntInit(IntAllocator(result));
int_replace(result, &zero);
} else {- In
Int.c:2103:
}
bool IntModMul(Int *result, const Int *a, const Int *b, const Int *modulus) {
ValidateInt(result);
ValidateInt(a);- In
Int.c:2114:
}
Int ar = IntInit(IntAllocator(result));
Int br = IntInit(IntAllocator(result));
Int prod = IntInit(IntAllocator(result));- In
Int.c:2115:
Int ar = IntInit(IntAllocator(result));
Int br = IntInit(IntAllocator(result));
Int prod = IntInit(IntAllocator(result));- In
Int.c:2116:
Int ar = IntInit(IntAllocator(result));
Int br = IntInit(IntAllocator(result));
Int prod = IntInit(IntAllocator(result));
if (!int_mod(&ar, a, modulus) || !int_mod(&br, b, modulus) || !int_mul(&prod, &ar, &br) ||- In
Int.c:2132:
}
bool IntModDiv(Int *result, const Int *a, const Int *b, const Int *modulus) {
ValidateInt(result);
ValidateInt(a);- In
Int.c:2143:
}
Int inverse = IntInit(IntAllocator(result));
Int value = IntInit(IntAllocator(result));
bool ok = false;- In
Int.c:2144:
Int inverse = IntInit(IntAllocator(result));
Int value = IntInit(IntAllocator(result));
bool ok = false;- In
Int.c:2165:
}
bool IntSquareMod(Int *result, const Int *value, const Int *modulus) {
return IntModMul(result, value, value, modulus);
}- In
Int.c:2169:
}
bool int_pow_u64_mod(Int *result, const Int *base, u64 exponent, const Int *modulus) {
ValidateInt(result);
ValidateInt(base);- In
Int.c:2178:
}
Int acc = IntInit(IntAllocator(result));
Int base_mod = IntInit(IntAllocator(result));- In
Int.c:2179:
Int acc = IntInit(IntAllocator(result));
Int base_mod = IntInit(IntAllocator(result));
if (!int_try_from_u64(&acc, 1, IntAllocator(result))) {- In
Int.c:2193:
while (exponent > 0) {
if (exponent & 1u) {
Int next = IntInit(IntAllocator(result));
if (!IntModMul(&next, &acc, &base_mod, modulus)) {- In
Int.c:2207:
exponent >>= 1u;
if (exponent > 0) {
Int next = IntInit(IntAllocator(result));
if (!IntModMul(&next, &base_mod, &base_mod, modulus)) {- In
Int.c:2225:
}
bool int_pow_mod(Int *result, const Int *base, const Int *exponent, const Int *modulus) {
ValidateInt(result);
ValidateInt(base);- In
Int.c:2236:
}
Int acc = IntInit(IntAllocator(result));
Int base_mod = IntInit(IntAllocator(result));
Int exp = IntInit(IntAllocator(exponent));- In
Int.c:2237:
Int acc = IntInit(IntAllocator(result));
Int base_mod = IntInit(IntAllocator(result));
Int exp = IntInit(IntAllocator(exponent));- In
Int.c:2238:
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:2250:
while (!IntIsZero(&exp)) {
if (int_is_odd(&exp)) {
Int next = IntInit(IntAllocator(result));
if (!IntModMul(&next, &acc, &base_mod, modulus)) {- In
Int.c:2270:
}
if (!IntIsZero(&exp)) {
Int next = IntInit(IntAllocator(result));
if (!IntModMul(&next, &base_mod, &base_mod, modulus)) {- In
Int.c:2290:
}
bool int_pow_i64_mod(Int *result, const Int *base, i64 exponent, const Int *modulus) {
if (exponent < 0) {
LOG_FATAL("Int exponent cannot be negative");- In
Int.c:2292:
bool int_pow_i64_mod(Int *result, const Int *base, i64 exponent, const Int *modulus) {
if (exponent < 0) {
LOG_FATAL("Int exponent cannot be negative");
}- In
Int.c:2298:
}
bool IntModInv(Int *result, const Int *value, const Int *modulus) {
ValidateInt(result);
ValidateInt(value);- In
Int.c:2308:
}
Int reduced = IntInit(IntAllocator(result));
SignedInt t = sint_init(IntAllocator(result));
SignedInt new_t = sint_from_u64(1, IntAllocator(result));- In
Int.c:2311:
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:2312:
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:2313:
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:2336:
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:2337:
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:2340:
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:2374:
if (IntEQ(&r, &one)) {
Int positive = IntInit(IntAllocator(result));
Int mag_mod = IntInit(IntAllocator(result));- In
Int.c:2375:
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:2428:
}
bool IntModSqrt(Int *result, const Int *value, const Int *modulus) {
ValidateInt(result);
ValidateInt(value);- In
Int.c:2438:
}
Int a = IntInit(IntAllocator(result));
bool ok = false;- In
Int.c:2447:
if (IntIsZero(&a)) {
Int zero = IntInit(IntAllocator(result));
int_replace(result, &zero);
IntDeinit(&a);- In
Int.c:2477:
}
if (int_mod_u64(modulus, 4) == 3) {
Int exponent = IntInit(IntAllocator(modulus));
Int root = IntInit(IntAllocator(result));- In
Int.c:2478:
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:2495:
{
Int q = IntInit(IntAllocator(modulus));
Int z = IntInit(IntAllocator(modulus));
Int c = IntInit(IntAllocator(result));- In
Int.c:2496:
{
Int q = IntInit(IntAllocator(modulus));
Int z = IntInit(IntAllocator(modulus));
Int c = IntInit(IntAllocator(result));
Int t = IntInit(IntAllocator(result));- In
Int.c:2497:
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:2498:
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:2499:
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:2500:
Int t = IntInit(IntAllocator(result));
Int r = IntInit(IntAllocator(result));
Int exponent = IntInit(IntAllocator(result));
u64 m = 0;- In
Int.c:2581:
while (int_compare_u64(&t, 1) != 0) {
Int t_power = IntInit(IntAllocator(&t));
u64 i = 0;- In
Int.c:2597:
for (i = 1; i < m; i++) {
Int next = IntInit(IntAllocator(result));
if (!IntSquareMod(&next, &t_power, modulus)) {- In
Int.c:2625:
{
Int b = IntInit(IntAllocator(&c));
Int b_sq = IntInit(IntAllocator(result));
Int next = IntInit(IntAllocator(result));- In
Int.c:2626:
{
Int b = IntInit(IntAllocator(&c));
Int b_sq = IntInit(IntAllocator(result));
Int next = IntInit(IntAllocator(result));- In
Int.c:2627:
Int b = IntInit(IntAllocator(&c));
Int b_sq = IntInit(IntAllocator(result));
Int next = IntInit(IntAllocator(result));
if (!IntTryClone(&b, &c)) {- In
Int.c:2645:
for (u64 j = 0; j + i + 1 < m; j++) {
Int square = IntInit(IntAllocator(result));
if (!IntSquareMod(&square, &b, modulus)) {- In
Int.c:2741:
}
bool IntIsProbablePrimeWithError(const Int *value, bool *error) {
static const u64 bases[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37};- In
Int.c:2769:
{
Int d = IntInit(IntAllocator(value));
Int n_minus_one = IntInit(IntAllocator(value));
u64 s = 0;- In
Int.c:2770:
{
Int d = IntInit(IntAllocator(value));
Int n_minus_one = IntInit(IntAllocator(value));
u64 s = 0;
bool probable = true;- In
Int.c:2795:
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:2796:
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:2829:
for (u64 r = 1; r < s; r++) {
Int next = IntInit(IntAllocator(value));
if (!IntSquareMod(&next, &x, value)) {- In
Int.c:2866:
}
bool IntNextPrime(Int *result, const Int *value) {
bool error = false;- In
Int.c:2873:
if (int_compare_u64(value, 1) <= 0) {
Int two = IntInit(IntAllocator(result));
if (!int_try_from_u64(&two, 2, IntAllocator(result))) {- In
Int.c:2883:
}
Int candidate = IntInit(IntAllocator(result));
if (!IntTryClone(&candidate, value)) {- In
Int.c:2895:
}
if (int_compare_u64(&candidate, 2) <= 0) {
Int two = IntInit(IntAllocator(result));
if (!int_try_from_u64(&two, 2, IntAllocator(result))) {- In
Int.Access.c:2:
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Container/Int.h>
#include <Misra/Std/Log.h>
#include <Misra/Types.h>- In
Int.Access.c:24:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFromBinary("00101000", &alloc.base);
bool result = IntBitLength(&value) == 6;- In
Int.Access.c:38:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFromBinary("0001001000110100", &alloc.base);
bool result = IntByteLength(&value) == 2;- In
Int.Access.c:52:
DefaultAllocator alloc = DefaultAllocatorInit();
Int zero = IntInit(&alloc.base);
Int non_zero = IntFrom(1, &alloc.base);- In
Int.Access.c:53:
Int zero = IntInit(&alloc.base);
Int non_zero = IntFrom(1, &alloc.base);
bool result = IntIsZero(&zero);- In
Int.Access.c:69:
DefaultAllocator alloc = DefaultAllocatorInit();
Int one = IntFrom(1, &alloc.base);
Int two = IntFrom(2, &alloc.base);- In
Int.Access.c:70:
Int one = IntFrom(1, &alloc.base);
Int two = IntFrom(2, &alloc.base);
bool result = IntIsOne(&one);- In
Int.Access.c:82:
bool test_int_parity(void) {
WriteFmt("Testing Int parity helpers\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Int.Access.c:86:
DefaultAllocator alloc = DefaultAllocatorInit();
Int even = IntFrom(42, &alloc.base);
Int odd = IntFrom(43, &alloc.base);- In
Int.Access.c:87:
Int even = IntFrom(42, &alloc.base);
Int odd = IntFrom(43, &alloc.base);
bool result = IntIsEven(&even);- In
Int.Access.c:105:
DefaultAllocator alloc = DefaultAllocatorInit();
Int small = IntFrom(UINT64_MAX, &alloc.base);
Int big = IntFrom(1, &alloc.base);- In
Int.Access.c:106:
Int small = IntFrom(UINT64_MAX, &alloc.base);
Int big = IntFrom(1, &alloc.base);
IntShiftLeft(&big, 64);- In
Int.Access.c:124:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(1025, &alloc.base);
bool error = true;- In
Int.Access.c:140:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFromBinary("1010000", &alloc.base);
Int zero = IntInit(&alloc.base);- In
Int.Access.c:141:
Int value = IntFromBinary("1010000", &alloc.base);
Int zero = IntInit(&alloc.base);
bool result = IntTrailingZeroCount(&value) == 4;- In
Int.Access.c:157:
DefaultAllocator alloc = DefaultAllocatorInit();
Int one = IntFrom(1, &alloc.base);
Int power = IntFrom(1, &alloc.base);
Int other = IntFrom(24, &alloc.base);- In
Int.Access.c:158:
Int one = IntFrom(1, &alloc.base);
Int power = IntFrom(1, &alloc.base);
Int other = IntFrom(24, &alloc.base);
Int zero = IntInit(&alloc.base);- In
Int.Access.c:159:
Int one = IntFrom(1, &alloc.base);
Int power = IntFrom(1, &alloc.base);
Int other = IntFrom(24, &alloc.base);
Int zero = IntInit(&alloc.base);- In
Int.Access.c:160:
Int power = IntFrom(1, &alloc.base);
Int other = IntFrom(24, &alloc.base);
Int zero = IntInit(&alloc.base);
IntShiftLeft(&power, 20);- In
Int.Access.c:182:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntInit(&alloc.base);
bool error = false;- In
Int.Access.c:194:
int main(void) {
WriteFmt("[INFO] Starting Int.Access tests\n\n");
TestFunction tests[] = {- In
Int.Access.c:210:
int total_tests = sizeof(tests) / sizeof(tests[0]);
return run_test_suite(tests, total_tests, NULL, 0, "Int.Access");
}- In
Int.Convert.c:3:
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Container/Int.h>
#include <Misra/Std/Log.h>
#include <Misra/Std/Memory.h>- In
Int.Convert.c:44:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(13, ALLOCATOR_OF(&alloc));
Str text = IntToBinary(&value);- In
Int.Convert.c:58:
bool test_int_bytes_le_round_trip(void) {
WriteFmt("Testing Int little-endian byte conversion\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Int.Convert.c:64:
u8 bytes[] = {0x34, 0x12, 0xEF, 0xCD};
u8 out[4] = {0};
Int value = IntFromBytesLE(bytes, sizeof(bytes), ALLOCATOR_OF(&alloc));
u64 written = IntToBytesLE(&value, out, sizeof(out));
Str text = IntToHexStr(&value);- In
Int.Convert.c:79:
bool test_int_bytes_be_round_trip(void) {
WriteFmt("Testing Int big-endian byte conversion\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Int.Convert.c:85:
u8 bytes[] = {0x12, 0x34, 0x56, 0x78};
u8 out[4] = {0};
Int value = IntFromBytesBE(bytes, sizeof(bytes), ALLOCATOR_OF(&alloc));
u64 written = IntToBytesBE(&value, out, sizeof(out));
Str text = IntToHexStr(&value);
bool test_int_binary_round_trip(void) {
WriteFmt("Testing Int binary round trip\n");
DefaultAllocator alloc = DefaultAllocatorInit(); DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFromBinary("001011", ALLOCATOR_OF(&alloc));
Str text = IntToBinary(&value);
bool test_int_decimal_round_trip(void) {
WriteFmt("Testing Int decimal round trip\n");
DefaultAllocator alloc = DefaultAllocatorInit();
Zstr digits = "123456789012345678901234567890";
Int value = IntFromStr(digits, ALLOCATOR_OF(&alloc));
Str text = IntToStr(&value);
bool test_int_radix_round_trip(void) {
WriteFmt("Testing Int radix conversion round trip\n");
DefaultAllocator alloc = DefaultAllocatorInit(); DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFromStrRadix("zz", 36, ALLOCATOR_OF(&alloc));
Str text = IntToStrRadix(&value, 36, false);
bool test_int_upper_hex_radix(void) {
WriteFmt("Testing Int uppercase radix conversion\n");
DefaultAllocator alloc = DefaultAllocatorInit(); DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(0xBEEF, ALLOCATOR_OF(&alloc));
Str text = IntToStrRadix(&value, 16, true); alloc.base.retry_limit = 4;
Int value = IntFrom(0xBEEF, ALLOCATOR_OF(&alloc));
ok = int_try_to_str_radix(&text, &value, 16, true, ALLOCATOR_OF(&alloc)); DefaultAllocator alloc = DefaultAllocatorInit();
Int lhs = IntFromBinary("0001011", ALLOCATOR_OF(&alloc));
Int rhs = IntFrom(11, ALLOCATOR_OF(&alloc));
Int lhs = IntFromBinary("0001011", ALLOCATOR_OF(&alloc));
Int rhs = IntFrom(11, ALLOCATOR_OF(&alloc));
bool result = IntCompare(&lhs, &rhs) == 0;
bool test_int_zero_binary(void) {
WriteFmt("Testing Int zero binary conversion\n");
DefaultAllocator alloc = DefaultAllocatorInit(); DefaultAllocator alloc = DefaultAllocatorInit();
Int zero = IntFromBinary("0", ALLOCATOR_OF(&alloc));
Str text = IntToBinary(&zero);
bool error = true;
bool test_int_binary_prefix_and_separators(void) {
WriteFmt("Testing Int binary prefix and separators\n");
DefaultAllocator alloc = DefaultAllocatorInit(); DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFromBinary("0b1010_0011", ALLOCATOR_OF(&alloc));
bool result = IntToU64(&value) == 163;
bool test_int_octal_round_trip(void) {
WriteFmt("Testing Int octal round trip\n");
DefaultAllocator alloc = DefaultAllocatorInit(); DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFromOctStr("0o7_55", ALLOCATOR_OF(&alloc));
Str text = IntToOctStr(&value);
bool test_int_hex_round_trip(void) {
WriteFmt("Testing Int hex round trip\n");
DefaultAllocator alloc = DefaultAllocatorInit();
Zstr hex = "deadbeefcafebabe1234";
Int value = IntFromHexStr(hex, ALLOCATOR_OF(&alloc));
Str text = IntToHexStr(&value); DefaultAllocator alloc = DefaultAllocatorInit();
Int parsed = IntFromBinary("10a1", ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromBinary(&value, "10a1");
Int parsed = IntFromBinary("10a1", ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromBinary(&value, "10a1"); DefaultAllocator alloc = DefaultAllocatorInit();
Int parsed = IntFromStr("12x3", ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromStr(&value, "12x3");
Int parsed = IntFromStr("12x3", ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromStr(&value, "12x3"); DefaultAllocator alloc = DefaultAllocatorInit();
Int parsed = IntFromHexStr("12g3", ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromHexStr(&value, "12g3");
Int parsed = IntFromHexStr("12g3", ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromHexStr(&value, "12g3"); DefaultAllocator alloc = DefaultAllocatorInit();
Int parsed = IntFromStrRadix("102", 2, ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromStrRadix(&value, "102", 2);
Int parsed = IntFromStrRadix("102", 2, ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromStrRadix(&value, "102", 2); DefaultAllocator alloc = DefaultAllocatorInit();
Int parsed = IntFromStrRadix("10", 1, ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromStrRadix(&value, "10", 1);
Int parsed = IntFromStrRadix("10", 1, ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromStrRadix(&value, "10", 1); DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(1, ALLOCATOR_OF(&alloc));
u64 out = 0;
bool error = false; DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(255, ALLOCATOR_OF(&alloc));
Str text = IntToStrRadix(&value, 37, false); DefaultAllocator alloc = DefaultAllocatorInit();
Int parsed = IntFromBinary((Zstr)NULL, ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromBinary(&value, (Zstr)NULL);
Int parsed = IntFromBinary((Zstr)NULL, ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromBinary(&value, (Zstr)NULL); DefaultAllocator alloc = DefaultAllocatorInit();
Int parsed = IntFromStr((Zstr)NULL, ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromStr(&value, (Zstr)NULL);
Int parsed = IntFromStr((Zstr)NULL, ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromStr(&value, (Zstr)NULL); DefaultAllocator alloc = DefaultAllocatorInit();
Int parsed = IntFromStrRadix((Zstr)NULL, 10, ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromStrRadix(&value, (Zstr)NULL, 10);
Int parsed = IntFromStrRadix((Zstr)NULL, 10, ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromStrRadix(&value, (Zstr)NULL, 10); DefaultAllocator alloc = DefaultAllocatorInit();
Int parsed = IntFromOctStr((Zstr)NULL, ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromOctStr(&value, (Zstr)NULL);
Int parsed = IntFromOctStr((Zstr)NULL, ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromOctStr(&value, (Zstr)NULL); DefaultAllocator alloc = DefaultAllocatorInit();
Int parsed = IntFromHexStr((Zstr)NULL, ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromHexStr(&value, (Zstr)NULL);
Int parsed = IntFromHexStr((Zstr)NULL, ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromHexStr(&value, (Zstr)NULL); DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(1, ALLOCATOR_OF(&alloc));
IntToBytesLE(&value, NULL, 1);
DefaultAllocatorDeinit(&alloc); DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(1, ALLOCATOR_OF(&alloc));
u8 byte = 0;
int main(void) {
WriteFmt("[INFO] Starting Int.Convert tests\n\n");
TestFunction tests[] = { int total_deadend_tests = sizeof(deadend_tests) / sizeof(deadend_tests[0]);
return run_test_suite(tests, total_tests, deadend_tests, total_deadend_tests, "Int.Convert");
}- In
Int.Type.c:2:
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Container/Int.h>
#include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Log.h>- In
Int.Type.c:19:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntInit(&alloc.base);
bool result = IntIsZero(&value);- In
Int.Type.c:34:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFromBinary("101101", &alloc.base);
IntClear(&value);- In
Int.Type.c:51:
DefaultAllocator alloc = DefaultAllocatorInit();
Int original = IntFromBinary("1011", &alloc.base);
Int clone = IntClone(&original);- In
Int.Type.c:52:
Int original = IntFromBinary("1011", &alloc.base);
Int clone = IntClone(&original);
bool result = IntEQ(&clone, &original);- In
Int.Type.c:79:
alloc.base.retry_limit = 5;
Int original = IntInit(&alloc);
BitVecPush(&original.bits, true);- In
Int.Type.c:85:
BitVecPush(&original.bits, true);
Int clone = IntClone(&original);
bool result =- In
Int.Type.c:103:
int main(void) {
WriteFmt("[INFO] Starting Int.Type tests\n\n");
TestFunction tests[] = {- In
Int.Type.c:113:
int total_tests = sizeof(tests) / sizeof(tests[0]);
return run_test_suite(tests, total_tests, NULL, 0, "Int.Type");
} #include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Container/Float.h>
#include <Misra/Std/Container/Int.h>
#include <Misra/Std/Container/Map.h>
#include <Misra/Std/Log.h> Float value = FloatFromStr("12.5", &alloc.base);
Float same = FloatFromStr("12.5", &alloc.base);
Int whole = IntFrom(12, &alloc.base);
Int next = IntFrom(13, &alloc.base); Float same = FloatFromStr("12.5", &alloc.base);
Int whole = IntFrom(12, &alloc.base);
Int next = IntFrom(13, &alloc.base);
bool result = (FloatCompare(&value, &same) == 0);- In
Io.Read.c:5:
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Container/Int.h>
#include <Misra/Std/Container/Float.h>
#include <Misra/Std/Io.h>- In
Io.Read.c:879:
bool test_int_reading(void) {
WriteFmt("Testing Int reading\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Io.Read.c:887:
bool success = true;
Int dec = IntInit(alloc_base);
Int hex = IntInit(alloc_base);
Int bin = IntInit(alloc_base);- In
Io.Read.c:888:
Int dec = IntInit(alloc_base);
Int hex = IntInit(alloc_base);
Int bin = IntInit(alloc_base);
Int oct = IntInit(alloc_base);- In
Io.Read.c:889:
Int dec = IntInit(alloc_base);
Int hex = IntInit(alloc_base);
Int bin = IntInit(alloc_base);
Int oct = IntInit(alloc_base);- In
Io.Read.c:890:
Int hex = IntInit(alloc_base);
Int bin = IntInit(alloc_base);
Int oct = IntInit(alloc_base);
Str dec_text = StrInit(&alloc); #include <Misra/Std/Zstr.h>
#include <Misra/Std/Container/Float.h>
#include <Misra/Std/Container/Int.h>
#include <Misra/Std/Log.h>
bool test_float_from_int_container(void) {
WriteFmt("Testing FloatFrom with Int container\n");
DefaultAllocator alloc = DefaultAllocatorInit(); DefaultAllocator alloc = DefaultAllocatorInit();
Int integer = IntFromStr("12345678901234567890", ALLOCATOR_OF(&alloc));
Float value = float_from_int(&integer, ALLOCATOR_OF(&alloc));
Str text = FloatToStr(&value);
Float value = FloatFromStr("1234500e-2", ALLOCATOR_OF(&alloc));
Int result_value = IntInit(ALLOCATOR_OF(&alloc));
Str text = StrInit(ALLOCATOR_OF(&alloc));
Float value = FloatFromStr("123.45", ALLOCATOR_OF(&alloc));
Int result_value = IntFrom(99, ALLOCATOR_OF(&alloc));
bool result = !FloatToInt(&result_value, &value);
Float value = FloatFromStr("-42", ALLOCATOR_OF(&alloc));
Int result_value = IntFrom(99, ALLOCATOR_OF(&alloc));
bool result = !FloatToInt(&result_value, &value);- In
Io.Write.c:5:
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Container/Int.h>
#include <Misra/Std/Container/Float.h>
#include <Misra/Std/Io.h>- In
Io.Write.c:586:
bool test_int_formatting(void) {
WriteFmt("Testing Int formatting\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Io.Write.c:594:
bool success = true;
Int big_dec = IntFromStr("123456789012345678901234567890", alloc_base);
Int hex_val = IntFromHexStr("deadbeefcafebabe1234", alloc_base);
Int bin_val = IntFromBinary("10100011", alloc_base);- In
Io.Write.c:595:
Int big_dec = IntFromStr("123456789012345678901234567890", alloc_base);
Int hex_val = IntFromHexStr("deadbeefcafebabe1234", alloc_base);
Int bin_val = IntFromBinary("10100011", alloc_base);
Int oct_val = IntFrom(493, alloc_base);- In
Io.Write.c:596:
Int big_dec = IntFromStr("123456789012345678901234567890", alloc_base);
Int hex_val = IntFromHexStr("deadbeefcafebabe1234", alloc_base);
Int bin_val = IntFromBinary("10100011", alloc_base);
Int oct_val = IntFrom(493, alloc_base);- In
Io.Write.c:597:
Int hex_val = IntFromHexStr("deadbeefcafebabe1234", alloc_base);
Int bin_val = IntFromBinary("10100011", alloc_base);
Int oct_val = IntFrom(493, alloc_base);
StrAppendFmt(&output, "{}", big_dec);- In
Float.Math.c:4:
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Container/Float.h>
#include <Misra/Std/Container/Int.h>
#include <Misra/Std/Log.h>- In
Float.Math.c:102:
Float a = FloatFromStr("1.25", &alloc.base);
Float b = FloatFromStr("0.75", &alloc.base);
Int whole = IntFrom(2, &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Float.Math.c:197:
Float a = FloatFromStr("5.5", &alloc.base);
Float b = FloatFromStr("0.5", &alloc.base);
Int whole = IntFrom(2, &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Float.Math.c:287:
Float a = FloatFromStr("1.5", &alloc.base);
Float b = FloatFromStr("2", &alloc.base);
Int whole = IntFrom(2, &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Float.Math.c:377:
Float a = FloatFromStr("7.5", &alloc.base);
Float b = FloatFromStr("2.5", &alloc.base);
Int whole = IntFrom(3, &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Int.Compare.c:2:
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Container/Int.h>
#include <Misra/Std/Container/Map.h>
#include <Misra/Std/Log.h>- In
Int.Compare.c:21:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(41, &alloc.base);
Int b = IntFrom(42, &alloc.base);
Int c = IntFromBinary("000101010", &alloc.base);- In
Int.Compare.c:22:
Int a = IntFrom(41, &alloc.base);
Int b = IntFrom(42, &alloc.base);
Int c = IntFromBinary("000101010", &alloc.base);- In
Int.Compare.c:23:
Int a = IntFrom(41, &alloc.base);
Int b = IntFrom(42, &alloc.base);
Int c = IntFromBinary("000101010", &alloc.base);
bool result = IntCompare(&a, &b) < 0;- In
Int.Compare.c:37:
bool test_int_compare_wrappers(void) {
WriteFmt("Testing Int compare wrappers\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Int.Compare.c:41:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(41, &alloc.base);
Int b = IntFrom(42, &alloc.base);
Int c = IntFromBinary("000101010", &alloc.base);- In
Int.Compare.c:42:
Int a = IntFrom(41, &alloc.base);
Int b = IntFrom(42, &alloc.base);
Int c = IntFromBinary("000101010", &alloc.base);- In
Int.Compare.c:43:
Int a = IntFrom(41, &alloc.base);
Int b = IntFrom(42, &alloc.base);
Int c = IntFromBinary("000101010", &alloc.base);
bool result = IntLT(&a, &b);- In
Int.Compare.c:66:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(42, &alloc.base);
Int same = IntFromBinary("00101010", &alloc.base);
Int big = IntFrom(1, &alloc.base);- In
Int.Compare.c:67:
Int value = IntFrom(42, &alloc.base);
Int same = IntFromBinary("00101010", &alloc.base);
Int big = IntFrom(1, &alloc.base);- In
Int.Compare.c:68:
Int value = IntFrom(42, &alloc.base);
Int same = IntFromBinary("00101010", &alloc.base);
Int big = IntFrom(1, &alloc.base);
IntShiftLeft(&big, 80);- In
Int.Compare.c:97:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(42u, &alloc.base);
Int b = IntFromBinary("101010", &alloc.base);
Int c = IntFrom(0u, &alloc.base);- In
Int.Compare.c:98:
Int a = IntFrom(42u, &alloc.base);
Int b = IntFromBinary("101010", &alloc.base);
Int c = IntFrom(0u, &alloc.base);
Int d = IntFrom(0u, &alloc.base);- In
Int.Compare.c:99:
Int a = IntFrom(42u, &alloc.base);
Int b = IntFromBinary("101010", &alloc.base);
Int c = IntFrom(0u, &alloc.base);
Int d = IntFrom(0u, &alloc.base); Int b = IntFromBinary("101010", &alloc.base);
Int c = IntFrom(0u, &alloc.base);
Int d = IntFrom(0u, &alloc.base);
bool result = (int_hash(&a, 0) == int_hash(&b, 0)); DefaultAllocator alloc = DefaultAllocatorInit();
Int zero = IntFrom(0u, &alloc.base);
Int one = IntFrom(1u, &alloc.base);
Int small = IntFrom(42u, &alloc.base);
Int zero = IntFrom(0u, &alloc.base);
Int one = IntFrom(1u, &alloc.base);
Int small = IntFrom(42u, &alloc.base);
Int large = IntFrom(1u, &alloc.base); Int zero = IntFrom(0u, &alloc.base);
Int one = IntFrom(1u, &alloc.base);
Int small = IntFrom(42u, &alloc.base);
Int large = IntFrom(1u, &alloc.base);
IntShiftLeft(&large, 80); Int one = IntFrom(1u, &alloc.base);
Int small = IntFrom(42u, &alloc.base);
Int large = IntFrom(1u, &alloc.base);
IntShiftLeft(&large, 80);
Int decimal = IntFromStr("12345678901234567890", &alloc.base); Int large = IntFrom(1u, &alloc.base);
IntShiftLeft(&large, 80);
Int decimal = IntFromStr("12345678901234567890", &alloc.base);
u64 h_zero = int_hash(&zero, 0); // GenericHash / GenericCompare-shaped helpers wire in directly.
bool test_int_hash_as_map_key(void) {
WriteFmt("Testing int_hash as Map<Int,u64> key\n");
DefaultAllocator alloc = DefaultAllocatorInit(); DefaultAllocator alloc = DefaultAllocatorInit();
Map(Int, u64) counts = MapInit(int_hash, int_compare, &alloc);
Int k1 = IntFrom(100u, &alloc.base); Map(Int, u64) counts = MapInit(int_hash, int_compare, &alloc);
Int k1 = IntFrom(100u, &alloc.base);
Int k2 = IntFrom(200u, &alloc.base);
Int k3 = IntFrom(100u, &alloc.base); // duplicate of k1 by value
Int k1 = IntFrom(100u, &alloc.base);
Int k2 = IntFrom(200u, &alloc.base);
Int k3 = IntFrom(100u, &alloc.base); // duplicate of k1 by value
Int k1 = IntFrom(100u, &alloc.base);
Int k2 = IntFrom(200u, &alloc.base);
Int k3 = IntFrom(100u, &alloc.base); // duplicate of k1 by value
MapInsertR(&counts, k1, 1u); MapInsertR(&counts, k2, 2u);
Int probe = IntFrom(100u, &alloc.base);
u64 *got = MapGetFirstPtr(&counts, probe);
Int missing = IntFrom(999u, &alloc.base); Int probe = IntFrom(100u, &alloc.base);
u64 *got = MapGetFirstPtr(&counts, probe);
Int missing = IntFrom(999u, &alloc.base);
u64 *gone = MapGetFirstPtr(&counts, missing);
int main(void) {
WriteFmt("[INFO] Starting Int.Compare tests\n\n");
TestFunction tests[] = {
int total_tests = sizeof(tests) / sizeof(tests[0]);
return run_test_suite(tests, total_tests, NULL, 0, "Int.Compare");
}- In
Int.Math.c:3:
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Container/Int.h>
#include <Misra/Std/Log.h>
#include <Misra/Types.h>- In
Int.Math.c:67:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(3, &alloc.base);
IntShiftLeft(&value, 4);- In
Int.Math.c:84:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFromBinary("110000", &alloc.base);
IntShiftRight(&value, 4);- In
Int.Math.c:101:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(255, &alloc.base);
Int b = IntFrom(1, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Int.Math.c:102:
Int a = IntFrom(255, &alloc.base);
Int b = IntFrom(1, &alloc.base);
Int result_value = IntInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Int.Math.c:103:
Int a = IntFrom(255, &alloc.base);
Int b = IntFrom(1, &alloc.base);
Int result_value = IntInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Int.Math.c:125:
DefaultAllocator alloc = DefaultAllocatorInit();
Int base = IntFrom(40, &alloc.base);
Int rhs = IntFrom(2, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Int.Math.c:126:
Int base = IntFrom(40, &alloc.base);
Int rhs = IntFrom(2, &alloc.base);
Int result_value = IntInit(&alloc.base);
Int huge = IntFromStr("123456789012345678901234567890", &alloc.base);- In
Int.Math.c:127:
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
Int.Math.c:128:
Int rhs = IntFrom(2, &alloc.base);
Int result_value = IntInit(&alloc.base);
Int huge = IntFromStr("123456789012345678901234567890", &alloc.base);
Str text = StrInit(&alloc.base);- In
Int.Math.c:158:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(256, &alloc.base);
Int b = IntFrom(1, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Int.Math.c:159:
Int a = IntFrom(256, &alloc.base);
Int b = IntFrom(1, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Int.Math.c:160:
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
Int.Math.c:177:
DefaultAllocator alloc = DefaultAllocatorInit();
Int base = IntFrom(40, &alloc.base);
Int rhs = IntFrom(2, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Int.Math.c:178:
Int base = IntFrom(40, &alloc.base);
Int rhs = IntFrom(2, &alloc.base);
Int result_value = IntInit(&alloc.base);
Int preserved = IntFrom(99, &alloc.base);- In
Int.Math.c:179:
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
Int.Math.c:180:
Int rhs = IntFrom(2, &alloc.base);
Int result_value = IntInit(&alloc.base);
Int preserved = IntFrom(99, &alloc.base);
Int huge = IntFromStr("12345678901234567890", &alloc.base);
Str text = StrInit(&alloc.base);- In
Int.Math.c:181:
Int result_value = IntInit(&alloc.base);
Int preserved = IntFrom(99, &alloc.base);
Int huge = IntFromStr("12345678901234567890", &alloc.base);
Str text = StrInit(&alloc.base);- In
Int.Math.c:215:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(3, &alloc.base);
Int b = IntFrom(5, &alloc.base);
Int result_value = IntFrom(99, &alloc.base);- In
Int.Math.c:216:
Int a = IntFrom(3, &alloc.base);
Int b = IntFrom(5, &alloc.base);
Int result_value = IntFrom(99, &alloc.base);- In
Int.Math.c:217:
Int a = IntFrom(3, &alloc.base);
Int b = IntFrom(5, &alloc.base);
Int result_value = IntFrom(99, &alloc.base);
bool result = !IntSub(&result_value, &a, &b);- In
Int.Math.c:234:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(21, &alloc.base);
Int b = IntFrom(6, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Int.Math.c:235:
Int a = IntFrom(21, &alloc.base);
Int b = IntFrom(6, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Int.Math.c:236:
Int a = IntFrom(21, &alloc.base);
Int b = IntFrom(6, &alloc.base);
Int result_value = IntInit(&alloc.base);
IntMul(&result_value, &a, &b);- In
Int.Math.c:254:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFromStr("12345678901234567890", &alloc.base);
Int result_value = IntInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Int.Math.c:255:
Int value = IntFromStr("12345678901234567890", &alloc.base);
Int result_value = IntInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Int.Math.c:275:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(0, &alloc.base);
Int b = IntFrom(12345, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Int.Math.c:276:
Int a = IntFrom(0, &alloc.base);
Int b = IntFrom(12345, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Int.Math.c:277:
Int a = IntFrom(0, &alloc.base);
Int b = IntFrom(12345, &alloc.base);
Int result_value = IntInit(&alloc.base);
IntMul(&result_value, &a, &b);- In
Int.Math.c:296:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(12345, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Int.Math.c:297:
Int value = IntFrom(12345, &alloc.base);
Int result_value = IntInit(&alloc.base);
IntSquare(&result_value, &value);- In
Int.Math.c:314:
DefaultAllocator alloc = DefaultAllocatorInit();
Int base = IntFrom(7, &alloc.base);
Int exponent = IntFrom(20, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Int.Math.c:315:
Int base = IntFrom(7, &alloc.base);
Int exponent = IntFrom(20, &alloc.base);
Int result_value = IntInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Int.Math.c:316:
Int base = IntFrom(7, &alloc.base);
Int exponent = IntFrom(20, &alloc.base);
Int result_value = IntInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Int.Math.c:341:
DefaultAllocator alloc = DefaultAllocatorInit();
Int dividend = IntFromStr("12345678901234567890", &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Int.Math.c:342:
Int dividend = IntFromStr("12345678901234567890", &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
Str qtext = StrInit(&alloc.base);- In
Int.Math.c:343:
Int dividend = IntFromStr("12345678901234567890", &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
Str qtext = StrInit(&alloc.base);- In
Int.Math.c:365:
DefaultAllocator alloc = DefaultAllocatorInit();
Int dividend = IntFrom(126, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Int.Math.c:366:
Int dividend = IntFrom(126, &alloc.base);
Int result_value = IntInit(&alloc.base);
IntDiv(&result_value, ÷nd, 10u);- In
Int.Math.c:383:
DefaultAllocator alloc = DefaultAllocatorInit();
Int dividend = IntFromStr("12345678901234567890", &alloc.base);
Int result_value = IntInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Int.Math.c:384:
Int dividend = IntFromStr("12345678901234567890", &alloc.base);
Int result_value = IntInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Int.Math.c:403:
DefaultAllocator alloc = DefaultAllocatorInit();
Int dividend = IntFrom(10, &alloc.base);
Int divisor = IntFrom(3, &alloc.base);
Int result_value = IntFrom(99, &alloc.base);- In
Int.Math.c:404:
Int dividend = IntFrom(10, &alloc.base);
Int divisor = IntFrom(3, &alloc.base);
Int result_value = IntFrom(99, &alloc.base);- In
Int.Math.c:405:
Int dividend = IntFrom(10, &alloc.base);
Int divisor = IntFrom(3, &alloc.base);
Int result_value = IntFrom(99, &alloc.base);
bool result = !IntDivExact(&result_value, ÷nd, &divisor);- In
Int.Math.c:422:
DefaultAllocator alloc = DefaultAllocatorInit();
Int dividend = IntFromStr("12345678901234567890", &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Int.Math.c:423:
Int dividend = IntFromStr("12345678901234567890", &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Int.Math.c:424:
Int dividend = IntFromStr("12345678901234567890", &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Int.Math.c:446:
DefaultAllocator alloc = DefaultAllocatorInit();
Int dividend = IntFrom(126, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Int.Math.c:447:
Int dividend = IntFrom(126, &alloc.base);
Int result_value = IntInit(&alloc.base);
IntMod(&result_value, ÷nd, 10u);- In
Int.Math.c:464:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFromStr("12345678901234567890", &alloc.base);
Int remainder = IntInit(&alloc.base);- In
Int.Math.c:465:
Int value = IntFromStr("12345678901234567890", &alloc.base);
Int remainder = IntInit(&alloc.base);
IntMod(&remainder, &value, 97u);- In
Int.Math.c:481:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(48, &alloc.base);
Int b = IntFrom(18, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Int.Math.c:482:
Int a = IntFrom(48, &alloc.base);
Int b = IntFrom(18, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Int.Math.c:483:
Int a = IntFrom(48, &alloc.base);
Int b = IntFrom(18, &alloc.base);
Int result_value = IntInit(&alloc.base);
IntGCD(&result_value, &a, &b);- In
Int.Math.c:501:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(21, &alloc.base);
Int b = IntFrom(6, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Int.Math.c:502:
Int a = IntFrom(21, &alloc.base);
Int b = IntFrom(6, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Int.Math.c:503:
Int a = IntFrom(21, &alloc.base);
Int b = IntFrom(6, &alloc.base);
Int result_value = IntInit(&alloc.base);
IntLCM(&result_value, &a, &b);- In
Int.Math.c:521:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(4096, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Int.Math.c:522:
Int value = IntFrom(4096, &alloc.base);
Int result_value = IntInit(&alloc.base);
IntRoot(&result_value, &value, 4);- In
Int.Math.c:539:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(200, &alloc.base);
Int root = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Int.Math.c:540:
Int value = IntFrom(200, &alloc.base);
Int root = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Int.Math.c:541:
Int value = IntFrom(200, &alloc.base);
Int root = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
IntRootRem(&root, &remainder, &value, 3);- In
Int.Math.c:560:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(200, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Int.Math.c:561:
Int value = IntFrom(200, &alloc.base);
Int result_value = IntInit(&alloc.base);
IntSqrt(&result_value, &value);- In
Int.Math.c:578:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(200, &alloc.base);
Int root = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Int.Math.c:579:
Int value = IntFrom(200, &alloc.base);
Int root = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Int.Math.c:580:
Int value = IntFrom(200, &alloc.base);
Int root = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
IntSqrtRem(&root, &remainder, &value);- In
Int.Math.c:599:
DefaultAllocator alloc = DefaultAllocatorInit();
Int square = IntFrom(144, &alloc.base);
Int non_square = IntFrom(145, &alloc.base);- In
Int.Math.c:600:
Int square = IntFrom(144, &alloc.base);
Int non_square = IntFrom(145, &alloc.base);
bool result = IntIsPerfectSquare(&square);- In
Int.Math.c:616:
DefaultAllocator alloc = DefaultAllocatorInit();
Int power = IntFrom(81, &alloc.base);
Int non_power = IntFrom(82, &alloc.base);
Int one = IntFrom(1, &alloc.base);- In
Int.Math.c:617:
Int power = IntFrom(81, &alloc.base);
Int non_power = IntFrom(82, &alloc.base);
Int one = IntFrom(1, &alloc.base);- In
Int.Math.c:618:
Int power = IntFrom(81, &alloc.base);
Int non_power = IntFrom(82, &alloc.base);
Int one = IntFrom(1, &alloc.base);
bool result = IntIsPerfectPower(&power);- In
Int.Math.c:636:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(5, &alloc.base);
Int p = IntFrom(7, &alloc.base);
Int b = IntFrom(9, &alloc.base);- In
Int.Math.c:637:
Int a = IntFrom(5, &alloc.base);
Int p = IntFrom(7, &alloc.base);
Int b = IntFrom(9, &alloc.base);
Int n = IntFrom(21, &alloc.base);- In
Int.Math.c:638:
Int a = IntFrom(5, &alloc.base);
Int p = IntFrom(7, &alloc.base);
Int b = IntFrom(9, &alloc.base);
Int n = IntFrom(21, &alloc.base);- In
Int.Math.c:639:
Int p = IntFrom(7, &alloc.base);
Int b = IntFrom(9, &alloc.base);
Int n = IntFrom(21, &alloc.base);
bool result = IntJacobi(&a, &p) == -1;- In
Int.Math.c:657:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(12345, &alloc.base);
Int mod = IntFrom(97, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Int.Math.c:658:
Int value = IntFrom(12345, &alloc.base);
Int mod = IntFrom(97, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Int.Math.c:659:
Int value = IntFrom(12345, &alloc.base);
Int mod = IntFrom(97, &alloc.base);
Int result_value = IntInit(&alloc.base);
IntSquareMod(&result_value, &value, &mod);- In
Int.Math.c:677:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(100, &alloc.base);
Int b = IntFrom(250, &alloc.base);
Int m = IntFrom(13, &alloc.base);- In
Int.Math.c:678:
Int a = IntFrom(100, &alloc.base);
Int b = IntFrom(250, &alloc.base);
Int m = IntFrom(13, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Int.Math.c:679:
Int a = IntFrom(100, &alloc.base);
Int b = IntFrom(250, &alloc.base);
Int m = IntFrom(13, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Int.Math.c:680:
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
Int.Math.c:699:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(5, &alloc.base);
Int b = IntFrom(9, &alloc.base);
Int m = IntFrom(13, &alloc.base);- In
Int.Math.c:700:
Int a = IntFrom(5, &alloc.base);
Int b = IntFrom(9, &alloc.base);
Int m = IntFrom(13, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Int.Math.c:701:
Int a = IntFrom(5, &alloc.base);
Int b = IntFrom(9, &alloc.base);
Int m = IntFrom(13, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Int.Math.c:702:
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
Int.Math.c:721:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(123, &alloc.base);
Int b = IntFrom(456, &alloc.base);
Int m = IntFrom(97, &alloc.base);- In
Int.Math.c:722:
Int a = IntFrom(123, &alloc.base);
Int b = IntFrom(456, &alloc.base);
Int m = IntFrom(97, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Int.Math.c:723:
Int a = IntFrom(123, &alloc.base);
Int b = IntFrom(456, &alloc.base);
Int m = IntFrom(97, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Int.Math.c:724:
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
Int.Math.c:743:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(10, &alloc.base);
Int b = IntFrom(3, &alloc.base);
Int m = IntFrom(13, &alloc.base);- In
Int.Math.c:744:
Int a = IntFrom(10, &alloc.base);
Int b = IntFrom(3, &alloc.base);
Int m = IntFrom(13, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Int.Math.c:745:
Int a = IntFrom(10, &alloc.base);
Int b = IntFrom(3, &alloc.base);
Int m = IntFrom(13, &alloc.base);
Int result_value = IntInit(&alloc.base);
Int check = IntInit(&alloc.base);- In
Int.Math.c:746:
Int b = IntFrom(3, &alloc.base);
Int m = IntFrom(13, &alloc.base);
Int result_value = IntInit(&alloc.base);
Int check = IntInit(&alloc.base);- In
Int.Math.c:747:
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
Int.Math.c:769:
DefaultAllocator alloc = DefaultAllocatorInit();
Int base = IntFrom(7, &alloc.base);
Int mod = IntFrom(13, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Int.Math.c:770:
Int base = IntFrom(7, &alloc.base);
Int mod = IntFrom(13, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Int.Math.c:771:
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
Int.Math.c:785:
bool test_int_pow_mod_integer_exponent(void) {
WriteFmt("Testing IntPowMod Int-exponent dispatch\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Int.Math.c:789:
DefaultAllocator alloc = DefaultAllocatorInit();
Int base = IntFrom(4, &alloc.base);
Int exp = IntFrom(13, &alloc.base);
Int mod = IntFrom(497, &alloc.base);- In
Int.Math.c:790:
Int base = IntFrom(4, &alloc.base);
Int exp = IntFrom(13, &alloc.base);
Int mod = IntFrom(497, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Int.Math.c:791:
Int base = IntFrom(4, &alloc.base);
Int exp = IntFrom(13, &alloc.base);
Int mod = IntFrom(497, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Int.Math.c:792:
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
Int.Math.c:811:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(3, &alloc.base);
Int mod = IntFrom(11, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Int.Math.c:812:
Int value = IntFrom(3, &alloc.base);
Int mod = IntFrom(11, &alloc.base);
Int result_value = IntInit(&alloc.base);
Int check = IntInit(&alloc.base);- In
Int.Math.c:813:
Int value = IntFrom(3, &alloc.base);
Int mod = IntFrom(11, &alloc.base);
Int result_value = IntInit(&alloc.base);
Int check = IntInit(&alloc.base);- In
Int.Math.c:814:
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
Int.Math.c:835:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(10, &alloc.base);
Int mod = IntFrom(13, &alloc.base);
Int root = IntInit(&alloc.base);- In
Int.Math.c:836:
Int value = IntFrom(10, &alloc.base);
Int mod = IntFrom(13, &alloc.base);
Int root = IntInit(&alloc.base);
Int check = IntInit(&alloc.base);- In
Int.Math.c:837:
Int value = IntFrom(10, &alloc.base);
Int mod = IntFrom(13, &alloc.base);
Int root = IntInit(&alloc.base);
Int check = IntInit(&alloc.base);- In
Int.Math.c:838:
Int mod = IntFrom(13, &alloc.base);
Int root = IntInit(&alloc.base);
Int check = IntInit(&alloc.base);
bool result = IntModSqrt(&root, &value, &mod);- In
Int.Math.c:857:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(3, &alloc.base);
Int mod = IntFrom(7, &alloc.base);
Int root = IntFrom(99, &alloc.base);- In
Int.Math.c:858:
Int value = IntFrom(3, &alloc.base);
Int mod = IntFrom(7, &alloc.base);
Int root = IntFrom(99, &alloc.base);- In
Int.Math.c:859:
Int value = IntFrom(3, &alloc.base);
Int mod = IntFrom(7, &alloc.base);
Int root = IntFrom(99, &alloc.base);
bool result = !IntModSqrt(&root, &value, &mod);- In
Int.Math.c:876:
DefaultAllocator alloc = DefaultAllocatorInit();
Int prime = IntFromStr("1000000007", &alloc.base);
Int composite = IntFrom(561, &alloc.base);- In
Int.Math.c:877:
Int prime = IntFromStr("1000000007", &alloc.base);
Int composite = IntFrom(561, &alloc.base);
bool result = IntIsProbablePrime(&prime);- In
Int.Math.c:893:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFromStr("1000000000", &alloc.base);
Int next = IntInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Int.Math.c:894:
Int value = IntFromStr("1000000000", &alloc.base);
Int next = IntInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Int.Math.c:914:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(6, &alloc.base);
Int mod = IntFrom(15, &alloc.base);
Int result_value = IntFrom(99, &alloc.base);- In
Int.Math.c:915:
Int value = IntFrom(6, &alloc.base);
Int mod = IntFrom(15, &alloc.base);
Int result_value = IntFrom(99, &alloc.base);- In
Int.Math.c:916:
Int value = IntFrom(6, &alloc.base);
Int mod = IntFrom(15, &alloc.base);
Int result_value = IntFrom(99, &alloc.base);
bool result = !IntModInv(&result_value, &value, &mod);- In
Int.Math.c:933:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(1, &alloc.base);
Int b = IntFrom(6, &alloc.base);
Int m = IntFrom(15, &alloc.base);- In
Int.Math.c:934:
Int a = IntFrom(1, &alloc.base);
Int b = IntFrom(6, &alloc.base);
Int m = IntFrom(15, &alloc.base);
Int result_value = IntFrom(99, &alloc.base);- In
Int.Math.c:935:
Int a = IntFrom(1, &alloc.base);
Int b = IntFrom(6, &alloc.base);
Int m = IntFrom(15, &alloc.base);
Int result_value = IntFrom(99, &alloc.base);- In
Int.Math.c:936:
Int b = IntFrom(6, &alloc.base);
Int m = IntFrom(15, &alloc.base);
Int result_value = IntFrom(99, &alloc.base);
bool result = !IntModDiv(&result_value, &a, &b, &m);- In
Int.Math.c:954:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(1, &alloc.base);
Int b = IntFrom(2, &alloc.base);- In
Int.Math.c:955:
Int a = IntFrom(1, &alloc.base);
Int b = IntFrom(2, &alloc.base);
IntAdd(NULL, &a, &b);- In
Int.Math.c:973:
bool test_int_div_by_zero(void) {
WriteFmt("Testing Int division by zero handling\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Int.Math.c:977:
DefaultAllocator alloc = DefaultAllocatorInit();
Int dividend = IntFrom(1, &alloc.base);
Int divisor = IntInit(&alloc.base);
Int quotient = IntFrom(99, &alloc.base);- In
Int.Math.c:978:
Int dividend = IntFrom(1, &alloc.base);
Int divisor = IntInit(&alloc.base);
Int quotient = IntFrom(99, &alloc.base);
Int remainder = IntFrom(77, &alloc.base);- In
Int.Math.c:979:
Int dividend = IntFrom(1, &alloc.base);
Int divisor = IntInit(&alloc.base);
Int quotient = IntFrom(99, &alloc.base);
Int remainder = IntFrom(77, &alloc.base);- In
Int.Math.c:980:
Int divisor = IntInit(&alloc.base);
Int quotient = IntFrom(99, &alloc.base);
Int remainder = IntFrom(77, &alloc.base);
bool result = !IntDivMod("ient, &remainder, ÷nd, &divisor);- In
Int.Math.c:1000:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(16, &alloc.base);
Int root = IntFrom(99, &alloc.base);
Int remainder = IntFrom(77, &alloc.base);- In
Int.Math.c:1001:
Int value = IntFrom(16, &alloc.base);
Int root = IntFrom(99, &alloc.base);
Int remainder = IntFrom(77, &alloc.base);
bool result = !IntRootRem(&root, &remainder, &value, 0);- In
Int.Math.c:1002:
Int value = IntFrom(16, &alloc.base);
Int root = IntFrom(99, &alloc.base);
Int remainder = IntFrom(77, &alloc.base);
bool result = !IntRootRem(&root, &remainder, &value, 0);- In
Int.Math.c:1020:
DefaultAllocator alloc = DefaultAllocatorInit();
Int dividend = IntFrom(10, &alloc.base);
Int quotient = IntFrom(99, &alloc.base);- In
Int.Math.c:1021:
Int dividend = IntFrom(10, &alloc.base);
Int quotient = IntFrom(99, &alloc.base);
IntDiv("ient, ÷nd, 0u);- In
Int.Math.c:1037:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(10, &alloc.base);
Int result_value = IntFrom(99, &alloc.base);- In
Int.Math.c:1038:
Int value = IntFrom(10, &alloc.base);
Int result_value = IntFrom(99, &alloc.base);
IntMod(&result_value, &value, 0u);- In
Int.Math.c:1054:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(10, &alloc.base);
Int b = IntFrom(3, &alloc.base);
Int m = IntInit(&alloc.base);- In
Int.Math.c:1055:
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
Int.Math.c:1056:
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
Int.Math.c:1057:
Int b = IntFrom(3, &alloc.base);
Int m = IntInit(&alloc.base);
Int result_value = IntFrom(99, &alloc.base);
bool result = !IntModDiv(&result_value, &a, &b, &m);- In
Int.Math.c:1075:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(3, &alloc.base);
Int n = IntFrom(8, &alloc.base);
int symbol = 99;- In
Int.Math.c:1076:
Int a = IntFrom(3, &alloc.base);
Int n = IntFrom(8, &alloc.base);
int symbol = 99;
bool error = false;- In
Int.Math.c:1096:
DefaultAllocator alloc = DefaultAllocatorInit();
Int base = IntFrom(2, &alloc.base);
Int mod = IntInit(&alloc.base);
Int result_value = IntInit(&alloc.base);- In
Int.Math.c:1097:
Int base = IntFrom(2, &alloc.base);
Int mod = IntInit(&alloc.base);
Int result_value = IntInit(&alloc.base);- In
Int.Math.c:1098:
Int base = IntFrom(2, &alloc.base);
Int mod = IntInit(&alloc.base);
Int result_value = IntInit(&alloc.base);
IntPowMod(&result_value, &base, 8u, &mod);- In
Int.Math.c:1106:
bool test_int_pow_mod_integer_zero_modulus(void) {
WriteFmt("Testing IntPowMod Int-exponent zero modulus handling\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Int.Math.c:1110:
DefaultAllocator alloc = DefaultAllocatorInit();
Int base = IntFrom(2, &alloc.base);
Int exp = IntFrom(8, &alloc.base);
Int mod = IntInit(&alloc.base);- In
Int.Math.c:1111:
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
Int.Math.c:1112:
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
Int.Math.c:1113:
Int exp = IntFrom(8, &alloc.base);
Int mod = IntInit(&alloc.base);
Int result_value = IntFrom(99, &alloc.base);
bool result = !IntPowMod(&result_value, &base, &exp, &mod);- In
Int.Math.c:1127:
int main(void) {
WriteFmt("[INFO] Starting Int.Math tests\n\n");
TestFunction tests[] = {- In
Int.Math.c:1190:
int total_deadend_tests = sizeof(deadend_tests) / sizeof(deadend_tests[0]);
return run_test_suite(tests, total_tests, deadend_tests, total_deadend_tests, "Int.Math");
}- In
Io.h:226:
#if FEATURE_INT
# define IOFMT_INT_CASE_(x, addr) \
Int: \
TO_TYPE_SPECIFIC_IO(Int, addr),
#else- In
Io.h:227:
# define IOFMT_INT_CASE_(x, addr) \
Int: \
TO_TYPE_SPECIFIC_IO(Int, addr),
#else
# define IOFMT_INT_CASE_(x, addr)- In
Io.h:751:
#endif
#if FEATURE_INT
bool _write_Int(Str *o, FmtInfo *fmt_info, Int *value);
#endif- In
Io.h:774:
#endif
#if FEATURE_INT
Zstr _read_Int(Zstr i, FmtInfo *fmt_info, Int *value);
#endif- In
Container.h:31:
#endif
#if FEATURE_INT
# include <Misra/Std/Container/Int.h>
#endif
#if FEATURE_FLOAT- In
Int.h:10:
#define MISRA_STD_CONTAINER_INT_H
#include "Int/Type.h"
#include "Int/Init.h"
#include "Int/Access.h"- In
Int.h:11:
#include "Int/Type.h"
#include "Int/Init.h"
#include "Int/Access.h"
#include "Int/Memory.h"- In
Int.h:12:
#include "Int/Type.h"
#include "Int/Init.h"
#include "Int/Access.h"
#include "Int/Memory.h"
#include "Int/Convert.h"- In
Int.h:13:
#include "Int/Init.h"
#include "Int/Access.h"
#include "Int/Memory.h"
#include "Int/Convert.h"
#include "Int/Private.h"- In
Int.h:14:
#include "Int/Access.h"
#include "Int/Memory.h"
#include "Int/Convert.h"
#include "Int/Private.h"
#include "Int/Compare.h"- In
Int.h:15:
#include "Int/Memory.h"
#include "Int/Convert.h"
#include "Int/Private.h"
#include "Int/Compare.h"
#include "Int/Math.h"- In
Int.h:16:
#include "Int/Convert.h"
#include "Int/Private.h"
#include "Int/Compare.h"
#include "Int/Math.h"- In
Int.h:17:
#include "Int/Private.h"
#include "Int/Compare.h"
#include "Int/Math.h"
#endif // MISRA_STD_CONTAINER_INT_H
- In
Init.h:11:
#include "Type.h"
#include <Misra/Std/Container/Int/Init.h>
///
- In
Access.h:10:
#define MISRA_STD_CONTAINER_FLOAT_ACCESS_H
#include <Misra/Std/Container/Int/Access.h>
#include "Type.h"- In
Convert.h:43:
///
# define FloatFrom(value, allocator_ptr) \
_Generic((value), Int *: float_from_int, unsigned char: float_from_u64, unsigned short: float_from_u64, unsigned int: float_from_u64, unsigned long: float_from_u64, unsigned long long: float_from_u64, signed char: float_from_i64, signed short: float_from_i64, signed int: float_from_i64, signed long: float_from_i64, signed long long: float_from_i64, float: float_from_f32, double: float_from_f64)( \
(value), \
ALLOCATOR_OF(allocator_ptr) \- In
Convert.h:64:
/// TAGS: Float, Convert, Int, Truncate
///
bool FloatToInt(Int *result, const Float *value);
///
- In
Math.h:143:
(b), \
Float *: float_add, \
Int *: float_add_int, \
unsigned char: float_add_u64, \
unsigned short: float_add_u64, \
- In
Math.h:178:
(b), \
Float *: float_sub, \
Int *: float_sub_int, \
unsigned char: float_sub_u64, \
unsigned short: float_sub_u64, \
- In
Math.h:214:
(b), \
Float *: float_mul, \
Int *: float_mul_int, \
unsigned char: float_mul_u64, \
unsigned short: float_mul_u64, \
- In
Math.h:252:
(b), \
Float *: float_div, \
Int *: float_div_int, \
unsigned char: float_div_u64, \
unsigned short: float_div_u64, \
- In
Type.h:10:
#define MISRA_STD_CONTAINER_FLOAT_TYPE_H
#include <Misra/Std/Container/Int/Type.h>
///
- In
Type.h:28:
typedef struct {
bool negative;
Int significand;
i64 exponent;
} Float;- In
Compare.h:94:
(rhs), \
Float *: float_compare, \
Int *: float_compare_int, \
unsigned char: float_compare_u64, \
unsigned short: float_compare_u64, \
- In
Compare.h:112:
(rhs), \
Float *: float_compare_with_error, \
Int *: float_compare_int_with_error, \
unsigned char: float_compare_u64_with_error, \
unsigned short: float_compare_u64_with_error, \
- In
Init.h:31:
///
#define IntInit(...) OVERLOAD(IntInit, __VA_ARGS__)
#define IntInit_0() ((Int) {.bits = BitVecInit_1(MisraScope)})
#define IntInit_1(allocator_ptr) ((Int) {.bits = BitVecInit_1(allocator_ptr)})- In
Init.h:32:
#define IntInit(...) OVERLOAD(IntInit, __VA_ARGS__)
#define IntInit_0() ((Int) {.bits = BitVecInit_1(MisraScope)})
#define IntInit_1(allocator_ptr) ((Int) {.bits = BitVecInit_1(allocator_ptr)})
///
- In
Init.h:45:
/// TAGS: Int, Deinit, Memory
///
static inline void IntDeinit(Int *value) {
ValidateInt(value);
BitVecDeinit(&value->bits);- In
Init.h:60:
/// TAGS: Int, Clear, Zero, Reset
///
static inline void IntClear(Int *value) {
ValidateInt(value);
BitVecClear(&value->bits);- In
Access.h:40:
/// TAGS: Int, Access, BitLength
///
u64 IntBitLength(const Int *value);
///
- In
Access.h:54:
/// TAGS: Int, Access, ByteLength
///
u64 IntByteLength(const Int *value);
///
- In
Access.h:66:
/// TAGS: Int, Math, Log2, Access
///
bool IntTryLog2(const Int *value, u64 *out);
///
- In
Access.h:80:
/// TAGS: Int, Math, Log2, Access
///
u64 IntLog2WithError(const Int *value, bool *error);
///
- In
Access.h:94:
/// TAGS: Int, Access, TrailingZeros
///
u64 IntTrailingZeroCount(const Int *value);
///
- In
Access.h:106:
/// TAGS: Int, Access, Predicate, IsZero
///
bool IntIsZero(const Int *value);
///
- In
Access.h:118:
/// TAGS: Int, Access, Predicate, IsOne
///
bool IntIsOne(const Int *value);
///
- In
Access.h:130:
/// TAGS: Int, Access, Predicate, IsEven
///
bool IntIsEven(const Int *value);
///
- In
Access.h:142:
/// TAGS: Int, Access, Predicate, IsOdd
///
bool IntIsOdd(const Int *value);
///
- In
Access.h:154:
/// TAGS: Int, Access, Predicate, FitsU64
///
bool IntFitsU64(const Int *value);
///
- In
Access.h:166:
/// TAGS: Int, Access, Predicate, PowerOfTwo
///
bool IntIsPowerOfTwo(const Int *value);
#ifdef __cplusplus- In
Access.h:172:
#endif
static inline u64 int_log2_no_error(const Int *value) {
return IntLog2WithError(value, NULL);
}- In
Convert.h:58:
/// TAGS: Int, Convert, U64
///
bool IntTryToU64(const Int *value, u64 *out);
///
- In
Convert.h:72:
/// TAGS: Int, Convert, U64
///
u64 IntToU64WithError(const Int *value, bool *error);
///
- In
Convert.h:92:
/// TAGS: Int, Convert, Bytes, LE
///
Int int_from_bytes_le(const u8 *bytes, u64 len, Allocator *alloc);
#define IntFromBytesLE(...) OVERLOAD(IntFromBytesLE, __VA_ARGS__)
#define IntFromBytesLE_2(bytes, len) int_from_bytes_le((bytes), (len), MisraScope)- In
Convert.h:115:
/// TAGS: Int, Convert, Bytes, LE
///
u64 IntToBytesLE(const Int *value, u8 *bytes, u64 max_len);
///
- In
Convert.h:136:
/// TAGS: Int, Convert, Bytes, BE
///
Int int_from_bytes_be(const u8 *bytes, u64 len, Allocator *alloc);
#define IntFromBytesBE(...) OVERLOAD(IntFromBytesBE, __VA_ARGS__)
#define IntFromBytesBE_2(bytes, len) int_from_bytes_be((bytes), (len), MisraScope)- In
Convert.h:159:
/// TAGS: Int, Convert, Bytes, BE
///
u64 IntToBytesBE(const Int *value, u8 *bytes, u64 max_len);
///
- In
Convert.h:182:
/// TAGS: Int, Convert, Parse, Radix
///
bool int_try_from_str_radix_zstr(Int *out, Zstr digits, u8 radix);
bool int_try_from_str_radix_str(Int *out, const Str *digits, u8 radix);
#define IntTryFromStrRadix(out, digits, radix) \- In
Convert.h:183:
///
bool int_try_from_str_radix_zstr(Int *out, Zstr digits, u8 radix);
bool int_try_from_str_radix_str(Int *out, const Str *digits, u8 radix);
#define IntTryFromStrRadix(out, digits, radix) \
_Generic((digits), Str *: int_try_from_str_radix_str, Zstr: int_try_from_str_radix_zstr, char *: int_try_from_str_radix_zstr)( \- In
Convert.h:202:
/// TAGS: Int, Convert, Radix, String
///
Int int_from_str_radix_zstr(Zstr digits, u8 radix, Allocator *alloc);
Int int_from_str_radix_str(const Str *digits, u8 radix, Allocator *alloc);
#define IntFromStrRadix(...) OVERLOAD(IntFromStrRadix, __VA_ARGS__)- In
Convert.h:203:
///
Int int_from_str_radix_zstr(Zstr digits, u8 radix, Allocator *alloc);
Int int_from_str_radix_str(const Str *digits, u8 radix, Allocator *alloc);
#define IntFromStrRadix(...) OVERLOAD(IntFromStrRadix, __VA_ARGS__)
#define IntFromStrRadix_2(digits, radix) \- In
Convert.h:236:
/// TAGS: Int, Convert, String, Radix, Allocator
///
bool int_try_to_str_radix(Str *out, const Int *value, u8 radix, bool uppercase, Allocator *alloc);
Str int_to_str_radix(const Int *value, u8 radix, bool uppercase, Allocator *alloc);- In
Convert.h:237:
///
bool int_try_to_str_radix(Str *out, const Int *value, u8 radix, bool uppercase, Allocator *alloc);
Str int_to_str_radix(const Int *value, u8 radix, bool uppercase, Allocator *alloc);
///
- In
Convert.h:258:
/// TAGS: Int, Convert, Parse, Decimal
///
bool int_try_from_str_zstr(Int *out, Zstr decimal);
bool int_try_from_str_str(Int *out, const Str *decimal);
#define IntTryFromStr(out, decimal) \- In
Convert.h:259:
///
bool int_try_from_str_zstr(Int *out, Zstr decimal);
bool int_try_from_str_str(Int *out, const Str *decimal);
#define IntTryFromStr(out, decimal) \
_Generic((decimal), Str *: int_try_from_str_str, Zstr: int_try_from_str_zstr, char *: int_try_from_str_zstr)( \- In
Convert.h:277:
/// TAGS: Int, Convert, String
///
Int int_from_str_zstr(Zstr decimal, Allocator *alloc);
Int int_from_str_str(const Str *decimal, Allocator *alloc);
#define IntFromStr(...) OVERLOAD(IntFromStr, __VA_ARGS__)- In
Convert.h:278:
///
Int int_from_str_zstr(Zstr decimal, Allocator *alloc);
Int int_from_str_str(const Str *decimal, Allocator *alloc);
#define IntFromStr(...) OVERLOAD(IntFromStr, __VA_ARGS__)
#define IntFromStr_1(decimal) \- In
Convert.h:307:
/// TAGS: Int, Convert, String, Decimal, Allocator
///
bool int_try_to_str(Str *out, const Int *value, Allocator *alloc);
Str int_to_str(const Int *value, Allocator *alloc);- In
Convert.h:308:
///
bool int_try_to_str(Str *out, const Int *value, Allocator *alloc);
Str int_to_str(const Int *value, Allocator *alloc);
///
- In
Convert.h:329:
/// TAGS: Int, Convert, Parse, Binary
///
bool int_try_from_binary_zstr(Int *out, Zstr binary);
bool int_try_from_binary_str(Int *out, const Str *binary);
#define IntTryFromBinary(out, binary) \- In
Convert.h:330:
///
bool int_try_from_binary_zstr(Int *out, Zstr binary);
bool int_try_from_binary_str(Int *out, const Str *binary);
#define IntTryFromBinary(out, binary) \
_Generic((binary), Str *: int_try_from_binary_str, Zstr: int_try_from_binary_zstr, char *: int_try_from_binary_zstr)( \- In
Convert.h:348:
/// TAGS: Int, Convert, Binary
///
Int int_from_binary_zstr(Zstr binary, Allocator *alloc);
Int int_from_binary_str(const Str *binary, Allocator *alloc);
#define IntFromBinary(...) OVERLOAD(IntFromBinary, __VA_ARGS__)- In
Convert.h:349:
///
Int int_from_binary_zstr(Zstr binary, Allocator *alloc);
Int int_from_binary_str(const Str *binary, Allocator *alloc);
#define IntFromBinary(...) OVERLOAD(IntFromBinary, __VA_ARGS__)
#define IntFromBinary_1(binary) \- In
Convert.h:379:
/// TAGS: Int, Convert, Binary
///
Str IntToBinary(const Int *value);
///
- In
Convert.h:400:
/// TAGS: Int, Convert, Parse, Octal
///
bool int_try_from_oct_str_zstr(Int *out, Zstr octal);
bool int_try_from_oct_str_str(Int *out, const Str *octal);
#define IntTryFromOctStr(out, octal) \- In
Convert.h:401:
///
bool int_try_from_oct_str_zstr(Int *out, Zstr octal);
bool int_try_from_oct_str_str(Int *out, const Str *octal);
#define IntTryFromOctStr(out, octal) \
_Generic((octal), Str *: int_try_from_oct_str_str, Zstr: int_try_from_oct_str_zstr, char *: int_try_from_oct_str_zstr)( \- In
Convert.h:419:
/// TAGS: Int, Convert, Oct
///
Int int_from_oct_str_zstr(Zstr octal, Allocator *alloc);
Int int_from_oct_str_str(const Str *octal, Allocator *alloc);
#define IntFromOctStr(...) OVERLOAD(IntFromOctStr, __VA_ARGS__)- In
Convert.h:420:
///
Int int_from_oct_str_zstr(Zstr octal, Allocator *alloc);
Int int_from_oct_str_str(const Str *octal, Allocator *alloc);
#define IntFromOctStr(...) OVERLOAD(IntFromOctStr, __VA_ARGS__)
#define IntFromOctStr_1(octal) \- In
Convert.h:450:
/// TAGS: Int, Convert, Oct
///
Str IntToOctStr(const Int *value);
///
- In
Convert.h:473:
/// TAGS: Int, Convert, Parse, Hex
///
bool int_try_from_hex_str_zstr(Int *out, Zstr hex);
bool int_try_from_hex_str_str(Int *out, const Str *hex);
#define IntTryFromHexStr(out, hex) \- In
Convert.h:474:
///
bool int_try_from_hex_str_zstr(Int *out, Zstr hex);
bool int_try_from_hex_str_str(Int *out, const Str *hex);
#define IntTryFromHexStr(out, hex) \
_Generic((hex), Str *: int_try_from_hex_str_str, Zstr: int_try_from_hex_str_zstr, char *: int_try_from_hex_str_zstr)( \- In
Convert.h:492:
/// TAGS: Int, Convert, Hex
///
Int int_from_hex_str_zstr(Zstr hex, Allocator *alloc);
Int int_from_hex_str_str(const Str *hex, Allocator *alloc);
#define IntFromHexStr(...) OVERLOAD(IntFromHexStr, __VA_ARGS__)- In
Convert.h:493:
///
Int int_from_hex_str_zstr(Zstr hex, Allocator *alloc);
Int int_from_hex_str_str(const Str *hex, Allocator *alloc);
#define IntFromHexStr(...) OVERLOAD(IntFromHexStr, __VA_ARGS__)
#define IntFromHexStr_1(hex) \- In
Convert.h:523:
/// TAGS: Int, Convert, Hex
///
Str IntToHexStr(const Int *value);
#ifdef __cplusplus- In
Convert.h:529:
#endif
static inline u64 int_to_u64_no_error(const Int *value) {
return IntToU64WithError(value, NULL);
}- In
Math.h:31:
/// TAGS: Int, Math, ShiftLeft, Bits
///
bool IntShiftLeft(Int *value, u64 positions);
///
/// Shift an integer right by the given number of bit positions.
- In
Math.h:47:
/// TAGS: Int, Math, ShiftRight, Bits
///
bool IntShiftRight(Int *value, u64 positions);
///
/// Add two integers.
- In
Math.h:64:
/// TAGS: Int, Math, Add
///
bool int_add(Int *result, const Int *a, const Int *b);
///
/// Subtract one integer from another.
- In
Math.h:82:
/// TAGS: Int, Math, Subtract
///
bool int_sub(Int *result, const Int *a, const Int *b);
///
/// Multiply two integers.
- In
Math.h:99:
/// TAGS: Int, Math, Multiply
///
bool int_mul(Int *result, const Int *a, const Int *b);
///
/// Square an integer.
- In
Math.h:115:
/// TAGS: Int, Math, Square
///
bool IntSquare(Int *result, const Int *value);
///
/// Raise an integer to an arbitrary-precision power.
- In
Math.h:132:
/// TAGS: Int, Math, Power, Exponentiation
///
bool int_pow(Int *result, const Int *base, const Int *exponent);
///
/// Divide one integer by another using floor division.
- In
Math.h:150:
/// TAGS: Int, Math, Divide, Quotient
///
bool int_div(Int *result, const Int *dividend, const Int *divisor);
///
/// Divide one integer by another only when the division is exact.
- In
Math.h:166:
/// TAGS: Int, Math, DivideExact
///
bool int_div_exact(Int *result, const Int *dividend, const Int *divisor);
///
/// Compute `dividend mod divisor`.
- In
Math.h:184:
/// TAGS: Int, Math, Modulo
///
bool int_mod(Int *result, const Int *dividend, const Int *divisor);
///
/// Compute quotient and remainder in one call.
- In
Math.h:203:
/// TAGS: Int, Math, Divide, Modulo
///
bool int_div_mod(Int *quotient, Int *remainder, const Int *dividend, const Int *divisor);
///
/// Compute the greatest common divisor of two integers.
- In
Math.h:220:
/// TAGS: Int, Math, GCD, NumberTheory
///
bool IntGCD(Int *result, const Int *a, const Int *b);
///
/// Compute the least common multiple of two integers.
- In
Math.h:237:
/// TAGS: Int, Math, LCM, NumberTheory
///
bool IntLCM(Int *result, const Int *a, const Int *b);
///
/// Compute the integer `degree`-th root of a value (floor).
- In
Math.h:254:
/// TAGS: Int, Math, Root, NumberTheory
///
bool IntRoot(Int *result, const Int *value, u64 degree);
///
/// Compute an integer root and the leftover remainder.
- In
Math.h:273:
/// TAGS: Int, Math, Root, Remainder
///
bool IntRootRem(Int *root, Int *remainder, const Int *value, u64 degree);
///
/// Compute the integer square root (floor).
- In
Math.h:288:
/// TAGS: Int, Math, Sqrt
///
bool IntSqrt(Int *result, const Int *value);
///
/// Compute the integer square root and remainder.
- In
Math.h:306:
/// TAGS: Int, Math, Sqrt, Remainder
///
bool IntSqrtRem(Int *root, Int *remainder, const Int *value);
///
/// Test whether a value is a perfect square.
- In
Math.h:320:
/// TAGS: Int, Math, PerfectSquare, Predicate
///
bool IntIsPerfectSquare(const Int *value);
///
/// Test whether a value is a perfect power.
- In
Math.h:334:
/// TAGS: Int, Math, PerfectPower, Predicate
///
bool IntIsPerfectPower(const Int *value);
///
/// Compute the Jacobi symbol `(a/n)`.
- In
Math.h:355:
/// TAGS: Int, Math, Jacobi, NumberTheory
///
bool IntTryJacobi(int *out, const Int *a, const Int *n);
///
- In
Math.h:375:
/// TAGS: Int, Math, Jacobi, NumberTheory
///
int IntJacobiWithError(const Int *a, const Int *n, bool *error);
///
/// Compute `(value^2) mod modulus`.
- In
Math.h:392:
/// TAGS: Int, Math, Modular, Square
///
bool IntSquareMod(Int *result, const Int *value, const Int *modulus);
///
/// Compute `(a + b) mod modulus`.
- In
Math.h:410:
/// TAGS: Int, Math, Modular, Add
///
bool IntModAdd(Int *result, const Int *a, const Int *b, const Int *modulus);
///
/// Compute `(a - b) mod modulus`.
- In
Math.h:429:
/// TAGS: Int, Math, Modular, Subtract
///
bool IntModSub(Int *result, const Int *a, const Int *b, const Int *modulus);
///
/// Compute `(a * b) mod modulus`.
- In
Math.h:447:
/// TAGS: Int, Math, Modular, Multiply
///
bool IntModMul(Int *result, const Int *a, const Int *b, const Int *modulus);
///
/// Compute modular division `a / b (mod modulus)`.
- In
Math.h:464:
/// TAGS: Int, Math, Modular, Divide
///
bool IntModDiv(Int *result, const Int *a, const Int *b, const Int *modulus);
///
/// Compute `(base^exponent) mod modulus`.
- In
Math.h:482:
/// TAGS: Int, Math, Modular, Power
///
bool int_pow_mod(Int *result, const Int *base, const Int *exponent, const Int *modulus);
///
/// Compute the multiplicative inverse of a value modulo `modulus`.
- In
Math.h:498:
/// TAGS: Int, Math, Modular, Inverse
///
bool IntModInv(Int *result, const Int *value, const Int *modulus);
///
/// Compute a modular square root.
- In
Math.h:514:
/// TAGS: Int, Math, Modular, Sqrt
///
bool IntModSqrt(Int *result, const Int *value, const Int *modulus);
///
/// Perform a probabilistic primality test.
- In
Math.h:532:
/// TAGS: Int, Math, Prime, Predicate
///
bool IntIsProbablePrimeWithError(const Int *value, bool *error);
///
/// Find the next probable prime greater than or equal to a value.
- In
Math.h:550:
/// TAGS: Int, Math, Prime, Search
///
bool IntNextPrime(Int *result, const Int *value);
static inline bool int_is_probable_prime_no_error(const Int *value) {- In
Math.h:552:
bool IntNextPrime(Int *result, const Int *value);
static inline bool int_is_probable_prime_no_error(const Int *value) {
return IntIsProbablePrimeWithError(value, NULL);
}- In
Math.h:602:
_Generic( \
(b), \
Int *: int_add, \
unsigned char: int_add_u64, \
unsigned short: int_add_u64, \
- In
Math.h:634:
_Generic( \
(b), \
Int *: int_sub, \
unsigned char: int_sub_u64, \
unsigned short: int_sub_u64, \
- In
Math.h:665:
_Generic( \
(b), \
Int *: int_mul, \
unsigned char: int_mul_u64, \
unsigned short: int_mul_u64, \
- In
Math.h:697:
_Generic( \
(exponent), \
Int *: int_pow, \
unsigned char: int_pow_u64, \
unsigned short: int_pow_u64, \
- In
Math.h:729:
_Generic( \
(divisor), \
Int *: int_div, \
unsigned char: int_div_u64, \
unsigned short: int_div_u64, \
- In
Math.h:759:
_Generic( \
(divisor), \
Int *: int_div_exact, \
unsigned char: int_div_exact_u64, \
unsigned short: int_div_exact_u64, \
- In
Math.h:791:
_Generic( \
(divisor), \
Int *: int_mod, \
unsigned char: int_mod_u64_into, \
unsigned short: int_mod_u64_into, \
- In
Math.h:826:
_Generic( \
(divisor), \
Int *: int_div_mod, \
unsigned char: int_div_mod_u64, \
unsigned short: int_div_mod_u64, \
- In
Math.h:861:
_Generic( \
(exponent), \
Int *: int_pow_mod, \
unsigned char: int_pow_u64_mod, \
unsigned short: int_pow_u64_mod, \
- In
Math.h:875:
#endif
static inline int int_jacobi_no_error(const Int *a, const Int *n) {
return IntJacobiWithError(a, n, NULL);
}- In
Memory.h:33:
/// TAGS: Int, Memory, Clone, Copy
///
bool IntTryClone(Int *out, const Int *value);
///
- In
Memory.h:54:
/// TAGS: Int, Memory, Clone, Copy
///
Int IntClone(const Int *value);
#ifdef __cplusplus- In
Type.h:26:
typedef struct {
BitVec bits;
} Int;
///
- In
Type.h:39:
/// TAGS: Int, Validate, Safety, Debug
///
static inline void ValidateInt(const Int *value) {
ValidateBitVec(value ? &value->bits : NULL);
}- In
Compare.h:78:
_Generic( \
(rhs), \
Int *: int_compare, \
unsigned char: int_compare_u64, \
unsigned short: int_compare_u64, \
Last updated on