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
Container.h:31:
#endif
#if FEATURE_INT
# include <Misra/Std/Container/Int.h>
#endif
#if FEATURE_FLOAT- In
Io.h:227:
#if FEATURE_INT
# define IOFMT_INT_CASE_(x, addr) \
Int: \
TO_TYPE_SPECIFIC_IO(Int, addr),
#else- In
Io.h:228:
# define IOFMT_INT_CASE_(x, addr) \
Int: \
TO_TYPE_SPECIFIC_IO(Int, addr),
#else
# define IOFMT_INT_CASE_(x, addr)- In
Io.h:758:
#endif
#if FEATURE_INT
bool _write_Int(Str *o, FmtInfo *fmt_info, Int *value);
#endif- In
Io.h:783:
#endif
#if FEATURE_INT
Zstr _read_Int(Zstr i, FmtInfo *fmt_info, Int *value);
#endif- 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
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
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
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
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
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
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
Compare.h:78:
_Generic( \
(rhs), \
Int *: int_compare, \
unsigned char: int_compare_u64, \
unsigned short: int_compare_u64, \
- 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
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
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
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
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
Io.c:27:
#endif
#if FEATURE_INT
# include <Misra/Std/Container/Int.h>
#endif
#if FEATURE_FLOAT- In
Io.c:3112:
#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:3131:
if (!buffer) {
LOG_ERROR("Failed to allocate buffer for Int character formatting");
return false;
}- In
Io.c:3309:
#if FEATURE_INT
Zstr _read_Int(Zstr i, FmtInfo *fmt_info, Int *value) {
if (!i || !value) {
LOG_FATAL("Invalid arguments");- In
Io.c:3315:
if (fmt_info && (fmt_info->flags & FMT_FLAG_CHAR)) {
LOG_ERROR("Character-format reads are not supported for Int");
return i;
}- In
Io.c:3329:
if (!StrIterRemainingLength(&si)) {
LOG_ERROR("Failed to parse Int: empty input");
return StrIterDataAt(&si, StrIterIndex(&si));
}- In
Io.c:3351:
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:3355:
}
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:3359:
}
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:3368:
if (StrIterIndex(&si) == StrIterIndex(&digits_saved)) {
LOG_ERROR("Failed to parse Int");
return start;
}- In
Io.c:3374:
char trailing = 0;
if (StrIterPeek(&si, &trailing) && trailing == '_') {
LOG_ERROR("Int reads do not accept digit separators");
return start;
}- In
Io.c:3379:
Str temp = StrInitFromCstr(start, StrIterIndex(&si) - StrIterIndex(&saved), IntAllocator(value));
Int parsed = IntInit(IntAllocator(value));
bool ok = IntTryFromStrRadix(&parsed, StrBegin(&temp), radix);- In
Int.c: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:19:
typedef struct {
bool negative;
Int magnitude;
} SignedInt;- In
Int.c:24:
#define INT_BITS(value) (&(value)->bits)
static void int_normalize(Int *value);
static inline u64 int_load_le8(const u8 *data, u64 bit_len, u64 off);
static inline void int_store_le8(u8 *data, u64 byte_len, u64 off, u64 value);- In
Int.c:28:
static inline void int_store_le8(u8 *data, u64 byte_len, u64 off, u64 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_from_i64_with_allocator(Int *out, i64 value, Allocator *alloc);
static bool int_try_clone_value(Int *out, const Int *value);- In
Int.c:29:
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_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:30:
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_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:33:
static u64 int_u64_bits(u64 value);
bool int_try_from_u64(Int *out, u64 value, Allocator *alloc) {
u64 bits = int_u64_bits(value);- In
Int.c:54:
}
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:56:
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:63:
}
static u64 int_significant_bits(const Int *value) {
ValidateInt(value);- In
Int.c:136:
}
static void int_replace(Int *dst, Int *src) {
IntDeinit(dst);
*dst = *src;- In
Int.c:141:
}
static void int_swap(Int *a, Int *b) {
Int tmp = *a;
*a = *b;- In
Int.c:142:
static void int_swap(Int *a, Int *b) {
Int tmp = *a;
*a = *b;
*b = tmp;- In
Int.c:229:
}
static bool sint_mul_unsigned(SignedInt *result, SignedInt *a, Int *b) {
SignedInt temp = sint_init(IntAllocator(&result->magnitude));- In
Int.c:242:
}
static void int_normalize(Int *value) {
ValidateInt(value);
BitVecResize(INT_BITS(value), int_significant_bits(value));- In
Int.c:247:
}
static bool int_is_odd(const Int *value) {
ValidateInt(value);
return BitVecLen(INT_BITS(value)) > 0 && BitVecGet(INT_BITS(value), 0);- In
Int.c:252:
}
static bool int_is_one(const Int *value) {
ValidateInt(value);
return IntBitLength(value) == 1 && BitVecGet(INT_BITS(value), 0);- In
Int.c:257:
}
static bool int_mul_u64_in_place(Int *value, u64 factor) {
Int lhs;
Int rhs;- In
Int.c:258:
static bool int_mul_u64_in_place(Int *value, u64 factor) {
Int lhs;
Int rhs;
Int result = IntInit(IntAllocator(value));- In
Int.c:259:
static bool int_mul_u64_in_place(Int *value, u64 factor) {
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:282:
}
static bool int_add_u64_in_place(Int *value, u64 addend) {
Int lhs;
Int rhs;- In
Int.c:283:
static bool int_add_u64_in_place(Int *value, u64 addend) {
Int lhs;
Int rhs;
Int result = IntInit(IntAllocator(value));- In
Int.c:284:
static bool int_add_u64_in_place(Int *value, u64 addend) {
Int lhs;
Int rhs;
Int result = IntInit(IntAllocator(value));- In
Int.c:285:
Int lhs;
Int rhs;
Int result = IntInit(IntAllocator(value));
if (!int_try_clone_value(&lhs, value)) {- In
Int.c:342:
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:343:
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:366:
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:390:
}
u64 IntBitLength(const Int *value) {
return int_significant_bits(value);
}- In
Int.c:394:
}
u64 IntByteLength(const Int *value) {
u64 bits = IntBitLength(value);
return bits == 0 ? 0 : CEIL_DIV(bits, 8u);- In
Int.c:399:
}
bool IntTryLog2(const Int *value, u64 *out) {
if (!value || !out) {
LOG_FATAL("Invalid arguments");- In
Int.c:415:
}
u64 IntLog2WithError(const Int *value, bool *error) {
u64 out = 0;
bool ok = IntTryLog2(value, &out);- In
Int.c:426:
}
u64 IntTrailingZeroCount(const Int *value) {
ValidateInt(value);- In
Int.c:438:
}
bool IntIsZero(const Int *value) {
return IntBitLength(value) == 0;
}- In
Int.c:442:
}
bool IntIsOne(const Int *value) {
return int_is_one(value);
}- In
Int.c:446:
}
bool IntIsEven(const Int *value) {
ValidateInt(value);
return !int_is_odd(value);- In
Int.c:451:
}
bool IntIsOdd(const Int *value) {
return int_is_odd(value);
}- In
Int.c:455:
}
bool IntFitsU64(const Int *value) {
ValidateInt(value);
return IntBitLength(value) <= 64;- In
Int.c:460:
}
bool IntIsPowerOfTwo(const Int *value) {
ValidateInt(value);- In
Int.c:466:
}
static bool int_try_clone_value(Int *out, const Int *value) {
if (!out || !value) {
LOG_FATAL("Invalid arguments");- In
Int.c:481:
}
bool IntTryClone(Int *out, const Int *value) {
return int_try_clone_value(out, value);
}- In
Int.c:485:
}
Int IntClone(const Int *value) {
Int clone;- In
Int.c:486:
Int IntClone(const Int *value) {
Int clone;
ValidateInt(value);- In
Int.c:494:
}
Int int_from_u64(u64 value, Allocator *alloc) {
Int result = IntInit(alloc);- In
Int.c:495:
Int int_from_u64(u64 value, Allocator *alloc) {
Int result = IntInit(alloc);
(void)int_try_from_u64(&result, value, alloc);- In
Int.c:501:
}
Int int_from_i64(i64 value, Allocator *alloc) {
if (value < 0) {
LOG_FATAL("Int cannot represent negative values");- In
Int.c:503:
Int int_from_i64(i64 value, Allocator *alloc) {
if (value < 0) {
LOG_FATAL("Int cannot represent negative values");
}- In
Int.c:509:
}
bool IntTryToU64(const Int *value, u64 *out) {
if (!value || !out) {
LOG_FATAL("Invalid arguments");- In
Int.c:517:
if (!IntFitsU64(value)) {
LOG_ERROR("Int value exceeds u64 range");
return false;
}- In
Int.c:525:
}
u64 IntToU64WithError(const Int *value, bool *error) {
u64 out = 0;
bool ok = IntTryToU64(value, &out);- In
Int.c:536:
}
Int int_from_bytes_le(const u8 *bytes, u64 len, Allocator *alloc) {
if (!bytes && len != 0) {
LOG_FATAL("bytes is NULL");- In
Int.c:541:
}
Int result = IntInit(alloc);
if (len == 0) {- In
Int.c:555:
}
u64 IntToBytesLE(const Int *value, u8 *bytes, u64 max_len) {
ValidateInt(value);- In
Int.c:591:
}
Int int_from_bytes_be(const u8 *bytes, u64 len, Allocator *alloc) {
if (!bytes && len != 0) {
LOG_FATAL("bytes is NULL");- In
Int.c:596:
}
Int result = IntInit(alloc);
for (u64 i = 0; i < len; i++) {- In
Int.c:609:
}
u64 IntToBytesBE(const Int *value, u8 *bytes, u64 max_len) {
ValidateInt(value);- In
Int.c:645:
}
bool int_try_from_str_zstr(Int *out, Zstr decimal) {
u64 start = 0;
u64 len = 0;- In
Int.c:661:
}
bool int_try_from_str_str(Int *out, const Str *decimal) {
u64 start = 0;- In
Int.c:675:
}
Int int_from_str_zstr(Zstr decimal, Allocator *alloc) {
Int out = IntInit(alloc);- In
Int.c:676:
Int int_from_str_zstr(Zstr decimal, Allocator *alloc) {
Int out = IntInit(alloc);
(void)int_try_from_str_zstr(&out, decimal);- In
Int.c:682:
}
Int int_from_str_str(const Str *decimal, Allocator *alloc) {
Int out = IntInit(alloc);- In
Int.c:683:
Int int_from_str_str(const Str *decimal, Allocator *alloc) {
Int out = IntInit(alloc);
(void)int_try_from_str_str(&out, decimal);- In
Int.c:689:
}
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:693:
}
Str int_to_str(const Int *value, Allocator *alloc) {
Str result;- In
Int.c:705:
}
bool int_try_from_str_radix_zstr(Int *out, Zstr digits, u8 radix) {
u64 start = 0;
u64 len = 0;- In
Int.c:720:
}
bool int_try_from_str_radix_str(Int *out, const Str *digits, u8 radix) {
u64 start = 0;- In
Int.c:733:
}
Int int_from_str_radix_zstr(Zstr digits, u8 radix, Allocator *alloc) {
Int out = IntInit(alloc);- In
Int.c:734:
Int int_from_str_radix_zstr(Zstr digits, u8 radix, Allocator *alloc) {
Int out = IntInit(alloc);
(void)int_try_from_str_radix_zstr(&out, digits, radix);- In
Int.c:740:
}
Int int_from_str_radix_str(const Str *digits, u8 radix, Allocator *alloc) {
Int out = IntInit(alloc);- In
Int.c:741:
Int int_from_str_radix_str(const Str *digits, u8 radix, Allocator *alloc) {
Int out = IntInit(alloc);
(void)int_try_from_str_radix_str(&out, digits, radix);- In
Int.c:747:
}
bool int_try_to_str_radix(Str *out, const Int *value, u8 radix, bool uppercase, Allocator *alloc) {
Int current;
Str result;- In
Int.c:748:
bool int_try_to_str_radix(Str *out, const Int *value, u8 radix, bool uppercase, Allocator *alloc) {
Int current;
Str result;- In
Int.c:788:
// once and reuse the quotient/remainder buffers (the quotient reserved once
// to the value's width) instead of allocating a fresh Int per digit-chunk.
Int chunk_divisor = IntInit(alloc);
Int quotient = IntInit(alloc);
Int remainder = IntInit(alloc);- In
Int.c:789:
// to the value's width) instead of allocating a fresh Int per digit-chunk.
Int chunk_divisor = IntInit(alloc);
Int quotient = IntInit(alloc);
Int remainder = IntInit(alloc);- In
Int.c:790:
Int chunk_divisor = IntInit(alloc);
Int quotient = IntInit(alloc);
Int remainder = IntInit(alloc);
if (!int_try_from_u64(&chunk_divisor, chunk, alloc) || !IntReserve("ient, IntBitLength(value))) {- In
Int.c:833:
// overwritten by the next division).
{
Int tmp = current;
current = quotient;
quotient = tmp;- In
Int.c:856:
}
Str int_to_str_radix(const Int *value, u8 radix, bool uppercase, Allocator *alloc) {
Str result;- In
Int.c:868:
}
bool int_try_from_binary_zstr(Int *out, Zstr binary) {
u64 start = 0;
u64 len = 0;- In
Int.c:884:
}
bool int_try_from_binary_str(Int *out, const Str *binary) {
u64 start = 0;- In
Int.c:899:
}
Int int_from_binary_zstr(Zstr binary, Allocator *alloc) {
Int out = IntInit(alloc);- In
Int.c:900:
Int int_from_binary_zstr(Zstr binary, Allocator *alloc) {
Int out = IntInit(alloc);
(void)int_try_from_binary_zstr(&out, binary);- In
Int.c:906:
}
Int int_from_binary_str(const Str *binary, Allocator *alloc) {
Int out = IntInit(alloc);- In
Int.c:907:
Int int_from_binary_str(const Str *binary, Allocator *alloc) {
Int out = IntInit(alloc);
(void)int_try_from_binary_str(&out, binary);- In
Int.c:913:
}
Str IntToBinary(const Int *value) {
return IntToStrRadix(value, 2, false);
}- In
Int.c:917:
}
bool int_try_from_oct_str_zstr(Int *out, Zstr octal) {
u64 start = 0;
u64 len = 0;- In
Int.c:933:
}
bool int_try_from_oct_str_str(Int *out, const Str *octal) {
u64 start = 0;- In
Int.c:948:
}
Int int_from_oct_str_zstr(Zstr octal, Allocator *alloc) {
Int out = IntInit(alloc);- In
Int.c:949:
Int int_from_oct_str_zstr(Zstr octal, Allocator *alloc) {
Int out = IntInit(alloc);
(void)int_try_from_oct_str_zstr(&out, octal);- In
Int.c:955:
}
Int int_from_oct_str_str(const Str *octal, Allocator *alloc) {
Int out = IntInit(alloc);- In
Int.c:956:
Int int_from_oct_str_str(const Str *octal, Allocator *alloc) {
Int out = IntInit(alloc);
(void)int_try_from_oct_str_str(&out, octal);- In
Int.c:962:
}
Str IntToOctStr(const Int *value) {
return IntToStrRadix(value, 8, false);
}- In
Int.c:966:
}
bool int_try_from_hex_str_zstr(Int *out, Zstr hex) {
u64 len = 0;- In
Int.c:977:
}
bool int_try_from_hex_str_str(Int *out, const Str *hex) {
if (!out || !hex) {
LOG_FATAL("Invalid arguments");- In
Int.c:985:
}
Int int_from_hex_str_zstr(Zstr hex, Allocator *alloc) {
Int out = IntInit(alloc);- In
Int.c:986:
Int int_from_hex_str_zstr(Zstr hex, Allocator *alloc) {
Int out = IntInit(alloc);
(void)int_try_from_hex_str_zstr(&out, hex);- In
Int.c:992:
}
Int int_from_hex_str_str(const Str *hex, Allocator *alloc) {
Int out = IntInit(alloc);- In
Int.c:993:
Int int_from_hex_str_str(const Str *hex, Allocator *alloc) {
Int out = IntInit(alloc);
(void)int_try_from_hex_str_str(&out, hex);- In
Int.c:999:
}
Str IntToHexStr(const Int *value) {
return IntToStrRadix(value, 16, false);
}- In
Int.c:1006:
// 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:1023:
i32 int_compare(const void *lhs, const void *rhs) {
const Int *a = (const Int *)lhs;
const Int *b = (const Int *)rhs;- In
Int.c:1024:
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:1060:
}
int int_compare_u64(const Int *lhs, u64 rhs) {
ValidateInt(lhs);- In
Int.c:1081:
}
int int_compare_i64(const Int *lhs, i64 rhs) {
ValidateInt(lhs);- In
Int.c:1091:
}
bool IntShiftLeft(Int *value, u64 positions) {
ValidateInt(value);- In
Int.c:1131:
}
bool IntShiftRight(Int *value, u64 positions) {
ValidateInt(value);- In
Int.c:1265:
}
bool int_add(Int *result, const Int *a, const Int *b) {
ValidateInt(result);
ValidateInt(a);- In
Int.c:1301:
}
bool int_add_u64(Int *result, const Int *value, u64 addend) {
ValidateInt(result);
ValidateInt(value);- In
Int.c:1305:
ValidateInt(value);
Int temp;
if (!int_try_clone_value(&temp, value)) {- In
Int.c:1318:
}
bool int_add_i64(Int *result, const Int *value, i64 addend) {
u64 magnitude = int_i64_magnitude(addend);- In
Int.c:1356:
}
bool int_sub(Int *result, const Int *a, const Int *b) {
ValidateInt(result);
ValidateInt(a);- In
Int.c:1391:
}
bool int_sub_u64(Int *result, const Int *value, u64 subtrahend) {
ValidateInt(result);
ValidateInt(value);- In
Int.c:1395:
ValidateInt(value);
Int rhs;
bool ok = false;- In
Int.c:1406:
}
bool int_sub_i64(Int *result, const Int *value, i64 subtrahend) {
u64 magnitude = int_i64_magnitude(subtrahend);- In
Int.c:1419:
}
bool int_mul(Int *result, const Int *a, const Int *b) {
ValidateInt(result);
ValidateInt(a);- In
Int.c:1432:
// read back limb-by-limb during accumulation, so it must stay independent of
// the operands: clone a/b only if they alias result.
Int a_copy = IntInit(IntAllocator(result));
Int b_copy = IntInit(IntAllocator(result));
bool ok = false;- In
Int.c:1433:
// the operands: clone a/b only if they alias result.
Int a_copy = IntInit(IntAllocator(result));
Int b_copy = IntInit(IntAllocator(result));
bool ok = false;- In
Int.c:1506:
}
bool int_mul_u64(Int *result, const Int *value, u64 factor) {
ValidateInt(result);
ValidateInt(value);- In
Int.c:1510:
ValidateInt(value);
Int temp;
if (!int_try_clone_value(&temp, value)) {- In
Int.c:1523:
}
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:1525:
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:1531:
}
bool IntSquare(Int *result, const Int *value) {
return int_mul(result, value, value);
}- In
Int.c:1535:
}
bool int_pow(Int *result, const Int *base, const Int *exponent) {
ValidateInt(result);
ValidateInt(base);- In
Int.c:1541:
if (!IntFitsU64(exponent)) {
LOG_ERROR("Int exponent exceeds u64 range");
return false;
}- In
Int.c:1548:
}
bool int_pow_u64(Int *result, const Int *base, u64 exponent) {
ValidateInt(result);
ValidateInt(base);- In
Int.c:1552:
ValidateInt(base);
Int acc;
Int current;- In
Int.c:1553:
Int acc;
Int current;
if (!int_try_from_u64(&acc, 1, IntAllocator(result))) {- In
Int.c:1566:
// int_mul writing in place, scratch keeps its capacity across iterations
// instead of a fresh Init per multiply.
Int scratch = IntInit(IntAllocator(result));
while (exponent > 0) {- In
Int.c:1597:
}
bool int_pow_i64(Int *result, const Int *base, i64 exponent) {
if (exponent < 0) {
LOG_FATAL("Int exponent cannot be negative");- In
Int.c:1599:
bool int_pow_i64(Int *result, const Int *base, i64 exponent) {
if (exponent < 0) {
LOG_FATAL("Int exponent cannot be negative");
}- In
Int.c:1605:
}
bool int_div_mod(Int *quotient, Int *remainder, const Int *dividend, const Int *divisor) {
ValidateInt(quotient);
ValidateInt(remainder);- In
Int.c:1621:
// dividend < divisor: quotient = 0, remainder = dividend.
if (int_compare(dividend, divisor) < 0) {
Int r0 = IntInit(IntAllocator(remainder));
if (!int_try_clone_value(&r0, dividend)) {- In
Int.c:1638:
// place and set the quotient bit. The loop reads dividend and divisor while
// mutating the outputs, so any input that aliases an output is cloned first.
Int dividend_copy = IntInit(IntAllocator(quotient));
Int divisor_copy = IntInit(IntAllocator(quotient));
bool ok = false;- In
Int.c:1639:
// mutating the outputs, so any input that aliases an output is cloned first.
Int dividend_copy = IntInit(IntAllocator(quotient));
Int divisor_copy = IntInit(IntAllocator(quotient));
bool ok = false;- In
Int.c:1734:
}
bool int_div(Int *result, const Int *dividend, const Int *divisor) {
Int remainder = IntInit(IntAllocator(result));- In
Int.c:1735:
bool int_div(Int *result, const Int *dividend, const Int *divisor) {
Int remainder = IntInit(IntAllocator(result));
// Quotient written straight into result (int_div_mod is in-place and clones
- In
Int.c:1748:
}
bool int_div_exact(Int *result, const Int *dividend, const Int *divisor) {
ValidateInt(result);
ValidateInt(dividend);- In
Int.c:1758:
}
Int quotient = IntInit(IntAllocator(result));
Int remainder = IntInit(IntAllocator(result));- In
Int.c:1759:
Int quotient = IntInit(IntAllocator(result));
Int remainder = IntInit(IntAllocator(result));
if (!int_div_mod("ient, &remainder, dividend, divisor)) {- In
Int.c:1777:
}
bool int_div_u64(Int *result, const Int *dividend, u64 divisor) {
Int divisor_value = IntInit(IntAllocator(dividend));- In
Int.c:1778:
bool int_div_u64(Int *result, const Int *dividend, u64 divisor) {
Int divisor_value = IntInit(IntAllocator(dividend));
if (!int_try_from_u64(&divisor_value, divisor, IntAllocator(dividend))) {- In
Int.c:1790:
}
bool int_div_i64(Int *result, const Int *dividend, i64 divisor) {
Int divisor_value = IntInit(IntAllocator(dividend));- In
Int.c:1791:
bool int_div_i64(Int *result, const Int *dividend, i64 divisor) {
Int divisor_value = IntInit(IntAllocator(dividend));
if (!int_try_from_i64_with_allocator(&divisor_value, divisor, IntAllocator(dividend))) {- In
Int.c:1803:
}
bool int_div_exact_u64(Int *result, const Int *dividend, u64 divisor) {
Int divisor_value = IntInit(IntAllocator(dividend));- In
Int.c:1804:
bool int_div_exact_u64(Int *result, const Int *dividend, u64 divisor) {
Int divisor_value = IntInit(IntAllocator(dividend));
if (!int_try_from_u64(&divisor_value, divisor, IntAllocator(dividend))) {- In
Int.c:1816:
}
bool int_div_exact_i64(Int *result, const Int *dividend, i64 divisor) {
Int divisor_value = IntInit(IntAllocator(dividend));- In
Int.c:1817:
bool int_div_exact_i64(Int *result, const Int *dividend, i64 divisor) {
Int divisor_value = IntInit(IntAllocator(dividend));
if (!int_try_from_i64_with_allocator(&divisor_value, divisor, IntAllocator(dividend))) {- In
Int.c:1829:
}
bool int_div_mod_u64(Int *quotient, Int *remainder, const Int *dividend, u64 divisor) {
Int divisor_value = IntInit(IntAllocator(dividend));- In
Int.c:1830:
bool int_div_mod_u64(Int *quotient, Int *remainder, const Int *dividend, u64 divisor) {
Int divisor_value = IntInit(IntAllocator(dividend));
if (!int_try_from_u64(&divisor_value, divisor, IntAllocator(dividend))) {- In
Int.c:1842:
}
bool int_div_mod_i64(Int *quotient, Int *remainder, const Int *dividend, i64 divisor) {
Int divisor_value = IntInit(IntAllocator(dividend));- In
Int.c:1843:
bool int_div_mod_i64(Int *quotient, Int *remainder, const Int *dividend, i64 divisor) {
Int divisor_value = IntInit(IntAllocator(dividend));
if (!int_try_from_i64_with_allocator(&divisor_value, divisor, IntAllocator(dividend))) {- In
Int.c:1855:
}
u64 int_div_u64_rem(Int *quotient, const Int *dividend, u64 divisor) {
ValidateInt(quotient);
ValidateInt(dividend);- In
Int.c:1864:
}
Int divisor_value = IntInit(IntAllocator(dividend));
Int remainder = IntInit(IntAllocator(quotient));
u64 rem = 0;- In
Int.c:1865:
Int divisor_value = IntInit(IntAllocator(dividend));
Int remainder = IntInit(IntAllocator(quotient));
u64 rem = 0;- In
Int.c:1886:
}
bool int_mod(Int *result, const Int *dividend, const Int *divisor) {
Int quotient = IntInit(IntAllocator(result));- In
Int.c:1887:
bool int_mod(Int *result, const Int *dividend, const Int *divisor) {
Int quotient = IntInit(IntAllocator(result));
// Remainder written straight into result (int_div_mod is in-place and clones
- In
Int.c:1900:
}
bool int_mod_u64_into(Int *result, const Int *dividend, u64 divisor) {
Int quotient = IntInit(IntAllocator(result));- In
Int.c:1901:
bool int_mod_u64_into(Int *result, const Int *dividend, u64 divisor) {
Int quotient = IntInit(IntAllocator(result));
bool ok = int_div_mod_u64("ient, result, dividend, divisor);- In
Int.c:1908:
}
bool int_mod_i64_into(Int *result, const Int *dividend, i64 divisor) {
Int quotient = IntInit(IntAllocator(result));- In
Int.c:1909:
bool int_mod_i64_into(Int *result, const Int *dividend, i64 divisor) {
Int quotient = IntInit(IntAllocator(result));
bool ok = int_div_mod_i64("ient, result, dividend, divisor);- In
Int.c:1916:
}
u64 int_mod_u64(const Int *value, u64 modulus) {
ValidateInt(value);- In
Int.c:1924:
}
Int quotient = IntInit(IntAllocator(value));
u64 rem = int_div_u64_rem("ient, value, modulus);- In
Int.c:1931:
}
bool IntGCD(Int *result, const Int *a, const Int *b) {
ValidateInt(result);
ValidateInt(a);- In
Int.c:1936:
ValidateInt(b);
Int x = IntInit(IntAllocator(a));
Int y = IntInit(IntAllocator(b));- In
Int.c:1937:
Int x = IntInit(IntAllocator(a));
Int y = IntInit(IntAllocator(b));
if (!int_try_clone_value(&x, a) || !int_try_clone_value(&y, b)) {- In
Int.c:1946:
while (!IntIsZero(&y)) {
Int r = IntInit(IntAllocator(result));
if (!int_mod(&r, &x, &y)) {- In
Int.c:1964:
}
bool IntLCM(Int *result, const Int *a, const Int *b) {
ValidateInt(result);
ValidateInt(a);- In
Int.c:1970:
if (IntIsZero(a) || IntIsZero(b)) {
Int zero = IntInit(IntAllocator(result));
int_replace(result, &zero);
return true;- In
Int.c:1975:
}
Int gcd = IntInit(IntAllocator(result));
Int quotient = IntInit(IntAllocator(result));
Int lcm = IntInit(IntAllocator(result));- In
Int.c:1976:
Int gcd = IntInit(IntAllocator(result));
Int quotient = IntInit(IntAllocator(result));
Int lcm = IntInit(IntAllocator(result));- In
Int.c:1977:
Int gcd = IntInit(IntAllocator(result));
Int quotient = IntInit(IntAllocator(result));
Int lcm = IntInit(IntAllocator(result));
if (!IntGCD(&gcd, a, b) || !int_div("ient, a, &gcd) || !int_mul(&lcm, "ient, b)) {- In
Int.c:1992:
}
bool IntRootRem(Int *root, Int *remainder, const Int *value, u64 degree) {
ValidateInt(root);
ValidateInt(remainder);- In
Int.c:2006:
if (IntIsZero(value)) {
Int zero_root = IntInit(IntAllocator(root));
Int zero_rem = IntInit(IntAllocator(remainder));- In
Int.c:2007:
if (IntIsZero(value)) {
Int zero_root = IntInit(IntAllocator(root));
Int zero_rem = IntInit(IntAllocator(remainder));
int_replace(root, &zero_root);- In
Int.c:2014:
}
if (degree == 1) {
Int exact_root = IntInit(IntAllocator(root));
Int zero_rem = IntInit(IntAllocator(remainder));- In
Int.c:2015:
if (degree == 1) {
Int exact_root = IntInit(IntAllocator(root));
Int zero_rem = IntInit(IntAllocator(remainder));
if (!IntTryClone(&exact_root, value)) {- In
Int.c:2029:
u64 bits = IntBitLength(value);
u64 high_shift = bits / degree;
Int low = IntInit(IntAllocator(root));
Int high = IntInit(IntAllocator(root));
Int best = IntInit(IntAllocator(root));- In
Int.c:2030:
u64 high_shift = bits / degree;
Int low = IntInit(IntAllocator(root));
Int high = IntInit(IntAllocator(root));
Int best = IntInit(IntAllocator(root));
Int one = IntInit(IntAllocator(root));- In
Int.c:2031:
Int low = IntInit(IntAllocator(root));
Int high = IntInit(IntAllocator(root));
Int best = IntInit(IntAllocator(root));
Int one = IntInit(IntAllocator(root));- In
Int.c:2032:
Int high = IntInit(IntAllocator(root));
Int best = IntInit(IntAllocator(root));
Int one = IntInit(IntAllocator(root));
if ((bits % degree) != 0) {- In
Int.c:2058:
while (IntLE(&low, &high)) {
Int sum = IntInit(IntAllocator(root));
Int mid = IntInit(IntAllocator(root));
Int mid_pow = IntInit(IntAllocator(root));- In
Int.c:2059:
while (IntLE(&low, &high)) {
Int sum = IntInit(IntAllocator(root));
Int mid = IntInit(IntAllocator(root));
Int mid_pow = IntInit(IntAllocator(root));
int cmp = 0;- In
Int.c:2060:
Int sum = IntInit(IntAllocator(root));
Int mid = IntInit(IntAllocator(root));
Int mid_pow = IntInit(IntAllocator(root));
int cmp = 0;- In
Int.c:2087:
if (cmp <= 0) {
Int next = IntInit(IntAllocator(root));
IntDeinit(&best);- In
Int.c:2113:
low = next;
} else {
Int next = IntInit(IntAllocator(root));
if (IntEQ(&mid, &one) || IntIsZero(&mid)) {- In
Int.c:2139:
{
Int power = IntInit(IntAllocator(root));
Int rem = IntInit(IntAllocator(remainder));- In
Int.c:2140:
{
Int power = IntInit(IntAllocator(root));
Int rem = IntInit(IntAllocator(remainder));
if (!int_pow_u64(&power, &best, degree) || !int_sub(&rem, value, &power)) {- In
Int.c:2164:
}
bool IntRoot(Int *result, const Int *value, u64 degree) {
Int root = IntInit(IntAllocator(result));
Int remainder = IntInit(IntAllocator(result));- In
Int.c:2165:
bool IntRoot(Int *result, const Int *value, u64 degree) {
Int root = IntInit(IntAllocator(result));
Int remainder = IntInit(IntAllocator(result));- In
Int.c:2166:
bool IntRoot(Int *result, const Int *value, u64 degree) {
Int root = IntInit(IntAllocator(result));
Int remainder = IntInit(IntAllocator(result));
if (!IntRootRem(&root, &remainder, value, degree)) {- In
Int.c:2179:
}
bool IntSqrtRem(Int *root, Int *remainder, const Int *value) {
return IntRootRem(root, remainder, value, 2);
}- In
Int.c:2183:
}
bool IntSqrt(Int *result, const Int *value) {
return IntRoot(result, value, 2);
}- In
Int.c:2187:
}
bool IntIsPerfectSquare(const Int *value) {
ValidateInt(value);- In
Int.c:2190:
ValidateInt(value);
Int root = IntInit(IntAllocator(value));
Int remainder = IntInit(IntAllocator(value));
bool result = false;- In
Int.c:2191:
Int root = IntInit(IntAllocator(value));
Int remainder = IntInit(IntAllocator(value));
bool result = false;- In
Int.c:2206:
}
bool IntIsPerfectPower(const Int *value) {
ValidateInt(value);- In
Int.c:2220:
for (u64 degree = 2; degree <= max_degree; degree++) {
Int root = IntInit(IntAllocator(value));
Int remainder = IntInit(IntAllocator(value));
bool exact = false;- In
Int.c:2221:
for (u64 degree = 2; degree <= max_degree; degree++) {
Int root = IntInit(IntAllocator(value));
Int remainder = IntInit(IntAllocator(value));
bool exact = false;- In
Int.c:2242:
}
bool IntTryJacobi(int *out, const Int *a, const Int *n) {
ValidateInt(a);
ValidateInt(n);- In
Int.c:2255:
}
Int aa = IntInit(IntAllocator(a));
Int nn = IntInit(IntAllocator(n));
int result = 1;- In
Int.c:2256:
Int aa = IntInit(IntAllocator(a));
Int nn = IntInit(IntAllocator(n));
int result = 1;- In
Int.c:2305:
}
int IntJacobiWithError(const Int *a, const Int *n, bool *error) {
int out = 0;
bool ok = IntTryJacobi(&out, a, n);- In
Int.c:2316:
}
bool IntModAdd(Int *result, const Int *a, const Int *b, const Int *modulus) {
ValidateInt(result);
ValidateInt(a);- In
Int.c:2330:
// instead of a full division: once both inputs are < modulus, sum < 2*modulus,
// so at most one subtraction reduces it (mirrors IntModSub).
Int ar = IntInit(IntAllocator(result));
Int br = IntInit(IntAllocator(result));
Int sum = IntInit(IntAllocator(result));- In
Int.c:2331:
// so at most one subtraction reduces it (mirrors IntModSub).
Int ar = IntInit(IntAllocator(result));
Int br = IntInit(IntAllocator(result));
Int sum = IntInit(IntAllocator(result));
const Int *ared = a;- In
Int.c:2332:
Int ar = IntInit(IntAllocator(result));
Int br = IntInit(IntAllocator(result));
Int sum = IntInit(IntAllocator(result));
const Int *ared = a;
const Int *bred = b;- In
Int.c:2333:
Int br = IntInit(IntAllocator(result));
Int sum = IntInit(IntAllocator(result));
const Int *ared = a;
const Int *bred = b;
bool ok = false;- In
Int.c:2334:
Int sum = IntInit(IntAllocator(result));
const Int *ared = a;
const Int *bred = b;
bool ok = false;- In
Int.c:2369:
}
bool IntModSub(Int *result, const Int *a, const Int *b, const Int *modulus) {
ValidateInt(result);
ValidateInt(a);- In
Int.c:2380:
}
Int ar = IntInit(IntAllocator(result));
Int br = IntInit(IntAllocator(result));- In
Int.c:2381:
Int ar = IntInit(IntAllocator(result));
Int br = IntInit(IntAllocator(result));
if (!int_mod(&ar, a, modulus) || !int_mod(&br, b, modulus)) {- In
Int.c:2396:
}
} else {
Int diff = IntInit(IntAllocator(result));
if (!int_sub(&diff, &br, &ar)) {- In
Int.c:2405:
}
if (IntIsZero(&diff)) {
Int zero = IntInit(IntAllocator(result));
int_replace(result, &zero);
} else {- In
Int.c:2424:
}
bool IntModMul(Int *result, const Int *a, const Int *b, const Int *modulus) {
ValidateInt(result);
ValidateInt(a);- In
Int.c:2438:
// not already < modulus (the common case in modpow/Miller-Rabin/Tonelli loops,
// where operands are already reduced - so both input divisions are skipped).
Int ar = IntInit(IntAllocator(result));
Int br = IntInit(IntAllocator(result));
Int prod = IntInit(IntAllocator(result));- In
Int.c:2439:
// where operands are already reduced - so both input divisions are skipped).
Int ar = IntInit(IntAllocator(result));
Int br = IntInit(IntAllocator(result));
Int prod = IntInit(IntAllocator(result));
const Int *ared = a;- In
Int.c:2440:
Int ar = IntInit(IntAllocator(result));
Int br = IntInit(IntAllocator(result));
Int prod = IntInit(IntAllocator(result));
const Int *ared = a;
const Int *bred = b;- In
Int.c:2441:
Int br = IntInit(IntAllocator(result));
Int prod = IntInit(IntAllocator(result));
const Int *ared = a;
const Int *bred = b;
bool ok = false;- In
Int.c:2442:
Int prod = IntInit(IntAllocator(result));
const Int *ared = a;
const Int *bred = b;
bool ok = false;- In
Int.c:2469:
}
bool IntModDiv(Int *result, const Int *a, const Int *b, const Int *modulus) {
ValidateInt(result);
ValidateInt(a);- In
Int.c:2480:
}
Int inverse = IntInit(IntAllocator(result));
Int value = IntInit(IntAllocator(result));
bool ok = false;- In
Int.c:2481:
Int inverse = IntInit(IntAllocator(result));
Int value = IntInit(IntAllocator(result));
bool ok = false;- In
Int.c:2502:
}
bool IntSquareMod(Int *result, const Int *value, const Int *modulus) {
return IntModMul(result, value, value, modulus);
}- In
Int.c:2506:
}
bool int_pow_u64_mod(Int *result, const Int *base, u64 exponent, const Int *modulus) {
ValidateInt(result);
ValidateInt(base);- In
Int.c:2515:
}
Int acc = IntInit(IntAllocator(result));
Int base_mod = IntInit(IntAllocator(result));- In
Int.c:2516:
Int acc = IntInit(IntAllocator(result));
Int base_mod = IntInit(IntAllocator(result));
if (!int_try_from_u64(&acc, 1, IntAllocator(result))) {- In
Int.c:2528:
}
Int scratch = IntInit(IntAllocator(result));
while (exponent > 0) {- In
Int.c:2559:
}
bool int_pow_mod(Int *result, const Int *base, const Int *exponent, const Int *modulus) {
ValidateInt(result);
ValidateInt(base);- In
Int.c:2570:
}
Int acc = IntInit(IntAllocator(result));
Int base_mod = IntInit(IntAllocator(result));
Int exp = IntInit(IntAllocator(exponent));- In
Int.c:2571:
Int acc = IntInit(IntAllocator(result));
Int base_mod = IntInit(IntAllocator(result));
Int exp = IntInit(IntAllocator(exponent));- In
Int.c:2572:
Int acc = IntInit(IntAllocator(result));
Int base_mod = IntInit(IntAllocator(result));
Int exp = IntInit(IntAllocator(exponent));
if (!int_try_from_u64(&acc, 1, IntAllocator(result)) || !IntTryClone(&exp, exponent) ||- In
Int.c:2582:
}
Int scratch = IntInit(IntAllocator(result));
while (!IntIsZero(&exp)) {- In
Int.c:2622:
}
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:2624:
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:2630:
}
bool IntModInv(Int *result, const Int *value, const Int *modulus) {
ValidateInt(result);
ValidateInt(value);- In
Int.c:2640:
}
Int reduced = IntInit(IntAllocator(result));
SignedInt t = sint_init(IntAllocator(result));
SignedInt new_t = sint_from_u64(1, IntAllocator(result));- In
Int.c:2643:
SignedInt t = sint_init(IntAllocator(result));
SignedInt new_t = sint_from_u64(1, IntAllocator(result));
Int r = IntInit(IntAllocator(modulus));
Int new_r = IntInit(IntAllocator(result));
Int one = int_from_u64(1, IntAllocator(result));- In
Int.c:2644:
SignedInt new_t = sint_from_u64(1, IntAllocator(result));
Int r = IntInit(IntAllocator(modulus));
Int new_r = IntInit(IntAllocator(result));
Int one = int_from_u64(1, IntAllocator(result));
bool ok = false;- In
Int.c:2645:
Int r = IntInit(IntAllocator(modulus));
Int new_r = IntInit(IntAllocator(result));
Int one = int_from_u64(1, IntAllocator(result));
bool ok = false;- In
Int.c:2668:
while (!IntIsZero(&new_r)) {
Int q = IntInit(IntAllocator(result));
Int rem = IntInit(IntAllocator(result));
SignedInt q_new_t = sint_init(IntAllocator(result));- In
Int.c:2669:
while (!IntIsZero(&new_r)) {
Int q = IntInit(IntAllocator(result));
Int rem = IntInit(IntAllocator(result));
SignedInt q_new_t = sint_init(IntAllocator(result));
SignedInt next_t = sint_init(IntAllocator(result));- In
Int.c:2672:
SignedInt q_new_t = sint_init(IntAllocator(result));
SignedInt next_t = sint_init(IntAllocator(result));
Int next_r = IntInit(IntAllocator(result));
if (!int_div_mod(&q, &rem, &r, &new_r) || !sint_mul_unsigned(&q_new_t, &new_t, &q) ||- In
Int.c:2706:
if (IntEQ(&r, &one)) {
Int positive = IntInit(IntAllocator(result));
Int mag_mod = IntInit(IntAllocator(result));- In
Int.c:2707:
if (IntEQ(&r, &one)) {
Int positive = IntInit(IntAllocator(result));
Int mag_mod = IntInit(IntAllocator(result));
if (!int_mod(&mag_mod, &t.magnitude, modulus)) {- In
Int.c:2760:
}
bool IntModSqrt(Int *result, const Int *value, const Int *modulus) {
ValidateInt(result);
ValidateInt(value);- In
Int.c:2770:
}
Int a = IntInit(IntAllocator(result));
bool ok = false;- In
Int.c:2779:
if (IntIsZero(&a)) {
Int zero = IntInit(IntAllocator(result));
int_replace(result, &zero);
IntDeinit(&a);- In
Int.c:2809:
}
if (int_mod_u64(modulus, 4) == 3) {
Int exponent = IntInit(IntAllocator(modulus));
Int root = IntInit(IntAllocator(result));- In
Int.c:2810:
if (int_mod_u64(modulus, 4) == 3) {
Int exponent = IntInit(IntAllocator(modulus));
Int root = IntInit(IntAllocator(result));
if (!IntTryClone(&exponent, modulus) || !int_add_u64(&exponent, &exponent, 1) || !IntShiftRight(&exponent, 2) ||- In
Int.c:2827:
{
Int q = IntInit(IntAllocator(modulus));
Int z = IntInit(IntAllocator(modulus));
Int c = IntInit(IntAllocator(result));- In
Int.c:2828:
{
Int q = IntInit(IntAllocator(modulus));
Int z = IntInit(IntAllocator(modulus));
Int c = IntInit(IntAllocator(result));
Int t = IntInit(IntAllocator(result));- In
Int.c:2829:
Int q = IntInit(IntAllocator(modulus));
Int z = IntInit(IntAllocator(modulus));
Int c = IntInit(IntAllocator(result));
Int t = IntInit(IntAllocator(result));
Int r = IntInit(IntAllocator(result));- In
Int.c:2830:
Int z = IntInit(IntAllocator(modulus));
Int c = IntInit(IntAllocator(result));
Int t = IntInit(IntAllocator(result));
Int r = IntInit(IntAllocator(result));
Int exponent = IntInit(IntAllocator(result));- In
Int.c:2831:
Int c = IntInit(IntAllocator(result));
Int t = IntInit(IntAllocator(result));
Int r = IntInit(IntAllocator(result));
Int exponent = IntInit(IntAllocator(result));
u64 m = 0;- In
Int.c:2832:
Int t = IntInit(IntAllocator(result));
Int r = IntInit(IntAllocator(result));
Int exponent = IntInit(IntAllocator(result));
u64 m = 0;- In
Int.c:2913:
while (int_compare_u64(&t, 1) != 0) {
Int t_power = IntInit(IntAllocator(&t));
u64 i = 0;- In
Int.c:2928:
}
Int scratch = IntInit(IntAllocator(result));
for (i = 1; i < m; i++) {- In
Int.c:2958:
{
Int b = IntInit(IntAllocator(&c));
Int b_sq = IntInit(IntAllocator(result));
Int next = IntInit(IntAllocator(result));- In
Int.c:2959:
{
Int b = IntInit(IntAllocator(&c));
Int b_sq = IntInit(IntAllocator(result));
Int next = IntInit(IntAllocator(result));- In
Int.c:2960:
Int b = IntInit(IntAllocator(&c));
Int b_sq = IntInit(IntAllocator(result));
Int next = IntInit(IntAllocator(result));
if (!IntTryClone(&b, &c)) {- In
Int.c:2978:
for (u64 j = 0; j + i + 1 < m; j++) {
Int square = IntInit(IntAllocator(result));
if (!IntSquareMod(&square, &b, modulus)) {- In
Int.c:3074:
}
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:3102:
{
Int d = IntInit(IntAllocator(value));
Int n_minus_one = IntInit(IntAllocator(value));
u64 s = 0;- In
Int.c:3103:
{
Int d = IntInit(IntAllocator(value));
Int n_minus_one = IntInit(IntAllocator(value));
u64 s = 0;
bool probable = true;- In
Int.c:3128:
for (u64 i = 0; i < (u64)(sizeof(bases) / sizeof(bases[0])); i++) {
Int base = IntInit(IntAllocator(value));
Int x = IntInit(IntAllocator(value));- In
Int.c:3129:
for (u64 i = 0; i < (u64)(sizeof(bases) / sizeof(bases[0])); i++) {
Int base = IntInit(IntAllocator(value));
Int x = IntInit(IntAllocator(value));
if (!int_try_from_u64(&base, bases[i], IntAllocator(value))) {- In
Int.c:3162:
for (u64 r = 1; r < s; r++) {
Int next = IntInit(IntAllocator(value));
if (!IntSquareMod(&next, &x, value)) {- In
Int.c:3199:
}
bool IntNextPrime(Int *result, const Int *value) {
bool error = false;- In
Int.c:3206:
if (int_compare_u64(value, 1) <= 0) {
Int two = IntInit(IntAllocator(result));
if (!int_try_from_u64(&two, 2, IntAllocator(result))) {- In
Int.c:3216:
}
Int candidate = IntInit(IntAllocator(result));
if (!IntTryClone(&candidate, value)) {- In
Int.c:3228:
}
if (int_compare_u64(&candidate, 2) <= 0) {
Int two = IntInit(IntAllocator(result));
if (!int_try_from_u64(&two, 2, IntAllocator(result))) {- In
Float.c: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:278:
{
Allocator *alloc = FloatAllocator(value);
Int ten = IntInit(alloc);
Int q = IntInit(alloc);
Int r = IntInit(alloc);- In
Float.c:279:
Allocator *alloc = FloatAllocator(value);
Int ten = IntInit(alloc);
Int q = IntInit(alloc);
Int r = IntInit(alloc);- In
Float.c:280:
Int ten = IntInit(alloc);
Int q = IntInit(alloc);
Int r = IntInit(alloc);
if (int_try_from_u64(&ten, 10, alloc)) {- In
Float.c:284:
if (int_try_from_u64(&ten, 10, alloc)) {
while (int_div_mod(&q, &r, &value->significand, &ten) && IntIsZero(&r)) {
Int tmp = value->significand;
value->significand = q;
q = tmp;- In
Float.c:375:
}
static bool float_try_from_int_value(Float *out, const Int *value) {
if (!out || !value) {
LOG_FATAL("Invalid arguments");- In
Float.c:408:
}
Float float_from_int(const Int *value, Allocator *alloc) {
Float result;- In
Float.c:433:
}
bool FloatToInt(Int *result, const Float *value) {
ValidateInt(result);
ValidateFloat(value);- In
Float.c:437:
ValidateFloat(value);
Int temp = IntInit(IntAllocator(result));
if (FloatIsNegative(value)) {- In
Float.c:451:
if (value->exponent >= 0) {
Int factor = IntInit(FloatAllocator(value));
if (!IntTryClone(&temp, &value->significand) ||- In
Float.c:468:
{
u64 places = (u64)(-value->exponent);
Int factor = IntInit(FloatAllocator(value));
bool ok = false;- In
Float.c:783:
}
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:805:
}
int float_compare_int(const Float *lhs, const Int *rhs) {
return float_compare_int_with_error(lhs, rhs, NULL);
}- In
Float.c:991:
}
bool float_add_int(Float *result, const Float *a, const Int *b) {
Float rhs = FloatInit(FloatAllocator(result));- In
Float.c:1062:
}
bool float_sub_int(Float *result, const Float *a, const Int *b) {
Float rhs = FloatInit(FloatAllocator(result));- In
Float.c:1136:
}
bool float_mul_int(Float *result, const Float *a, const Int *b) {
Float rhs = FloatInit(FloatAllocator(result));- In
Float.c:1193:
bool float_div(Float *result, const Float *a, const Float *b, u64 precision) {
Float temp = FloatInit(FloatAllocator(result));
Int scale = IntInit(FloatAllocator(result));
Int scaled = IntInit(FloatAllocator(result));- In
Float.c:1194:
Float temp = FloatInit(FloatAllocator(result));
Int scale = IntInit(FloatAllocator(result));
Int scaled = IntInit(FloatAllocator(result));
ValidateFloat(result);- In
Float.c:1236:
}
bool float_div_int(Float *result, const Float *a, const Int *b, u64 precision) {
Float rhs = FloatInit(FloatAllocator(result));
bool ok = false;- In
Compare.c:4:
#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>- In
Compare.c:133:
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);- In
Compare.c:134:
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
Compare.c:289:
Float v = FloatFromStr("3", &alloc.base);
Int i3 = IntFrom(3, &alloc.base);
bool err = true;
bool ok = true;- In
Compare.c:525:
Float lhs = FloatFromStr("7", &alloc.base);
Int less = IntFrom(3, &alloc.base);
Int same = IntFrom(7, &alloc.base);
Int more = IntFrom(9, &alloc.base);- In
Compare.c:526:
Float lhs = FloatFromStr("7", &alloc.base);
Int less = IntFrom(3, &alloc.base);
Int same = IntFrom(7, &alloc.base);
Int more = IntFrom(9, &alloc.base);- In
Compare.c:527:
Int less = IntFrom(3, &alloc.base);
Int same = IntFrom(7, &alloc.base);
Int more = IntFrom(9, &alloc.base);
bool error = true;- In
Compare.c:742:
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("3.5", &dbg.base);
Int b = IntFrom(3, &dbg.base);
int cmp = FloatCompare(&a, &b);- In
Type.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
Type.c:175:
Float neg = FloatFromStr("-5", &alloc.base);
Int out = IntInit(&alloc.base);
bool ok = (FloatToInt(&out, &neg) == false);- In
Type.c:207:
.exponent = -1,
};
Int result = IntInit(&alloc.base);
bool ok = FloatToInt(&result, &value);- In
Type.c:228:
Float value = FloatFromStr("120", &alloc.base);
Int result = IntInit(&alloc.base);
bool ok = FloatToInt(&result, &value);- In
Type.c:249:
Float value = FloatFromStr("0", &alloc.base);
Int result = IntFromStr("999", &alloc.base);
bool ok = FloatToInt(&result, &value);- In
Type.c:267:
Float value = FloatFromStr("-7", &alloc.base);
Int result = IntInit(&alloc.base);
bool ok = FloatToInt(&result, &value);- In
Math.c:5:
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Container/Float.h>
#include <Misra/Std/Container/Int.h>
#include <Misra/Std/Log.h>- In
Math.c:148:
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
Math.c:243:
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
Math.c:333:
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
Math.c:423:
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
Math.c:794:
bool test_m12_div_int_by_zero_returns_false(void) {
WriteFmt("Testing FloatDiv(Int 0) returns false\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Math.c:800:
Float a = FloatFromStr("6", &alloc.base);
Float result = FloatInit(&alloc.base);
Int zero = IntFrom(0u, &alloc.base);
// Real float_div rejects division by zero -> false.
- In
Math.c:1139:
Float a = FloatFromStr("1.5", &dbg.base);
Float r = FloatInit(&dbg.base);
Int b = IntFrom(2, &dbg.base);
bool ok = FloatAdd(&r, &a, &b);- In
Math.c:1233:
Float a = FloatFromStr("5.5", &dbg.base);
Float r = FloatInit(&dbg.base);
Int b = IntFrom(2, &dbg.base);
bool ok = FloatSub(&r, &a, &b);- In
Math.c:1310:
Float a = FloatFromStr("1.5", &dbg.base);
Float r = FloatInit(&dbg.base);
Int b = IntFrom(4, &dbg.base);
bool ok = FloatMul(&r, &a, &b);- In
Math.c:1387:
Float a = FloatFromStr("1", &dbg.base);
Float r = FloatInit(&dbg.base);
Int b = IntFrom(4, &dbg.base);
bool ok = FloatDiv(&r, &a, &b, 6u);- In
Convert.c:5:
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Container/Float.h>
#include <Misra/Std/Container/Int.h>
#include <Misra/Std/Log.h>- In
Convert.c:83:
bool test_float_from_int_container(void) {
WriteFmt("Testing FloatFrom with Int container\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Convert.c:87:
DefaultAllocator alloc = DefaultAllocatorInit();
Int integer = IntFromStr("12345678901234567890", ALLOCATOR_OF(&alloc));
Float value = float_from_int(&integer, ALLOCATOR_OF(&alloc));
Str text = FloatToStr(&value);- In
Convert.c:106:
Float value = FloatFromStr("1234500e-2", ALLOCATOR_OF(&alloc));
Int result_value = IntInit(ALLOCATOR_OF(&alloc));
Str text = StrInit(ALLOCATOR_OF(&alloc));- In
Convert.c:126:
Float value = FloatFromStr("123.45", ALLOCATOR_OF(&alloc));
Int result_value = IntFrom(99, ALLOCATOR_OF(&alloc));
bool result = !FloatToInt(&result_value, &value);- In
Convert.c:143:
Float value = FloatFromStr("-42", ALLOCATOR_OF(&alloc));
Int result_value = IntFrom(99, ALLOCATOR_OF(&alloc));
bool result = !FloatToInt(&result_value, &value);- In
Convert.c:310:
DefaultAllocator alloc = DefaultAllocatorInit();
Int whole = IntFrom(100, &alloc.base);
Float value = FloatFrom(&whole, &alloc.base);- In
Convert.c:330:
DefaultAllocator alloc = DefaultAllocatorInit();
Int whole = IntFrom(100, &alloc.base);
Float value = FloatFrom(&whole, &alloc.base);
Str text = FloatToStr(&value);- In
Convert.c:352:
DefaultAllocator alloc = DefaultAllocatorInit();
Int whole = IntFrom(2000, &alloc.base);
Float value = FloatFrom(&whole, &alloc.base);- In
Convert.c:628:
Float value = FloatFrom(4503599627370496.0, &alloc.base); // 2^52, binexp == 0
Int whole = IntFromStr("4503599627370496", &alloc.base);
bool result = (FloatExponent(&value) == 0);- In
Convert.c:714:
Float v = FloatFromStr("1e3", &dbg.base); // exponent 3 > 0 -> pow10
Int r = IntInit(&dbg.base);
bool ok = FloatToInt(&r, &v); // drives float_pow10 + success path
- In
Convert.c:736:
Float v = FloatFromStr("12e4", &dbg.base); // significand 12, exp 4
Int r = IntFrom(999999999u, &dbg.base); // pre-populated dest
bool ok = FloatToInt(&r, &v);- In
Convert.c:758:
Float v = FloatFromStr("150e-1", &dbg.base); // 15.0, exact integer 15
Int r = IntFrom(777u, &dbg.base); // pre-populated dest
bool ok = FloatToInt(&r, &v);- In
Convert.c:784:
Float v = FloatFromStr("1.5", &dbg.base); // significand 15, exponent -1
Int r = IntFrom(777u, &dbg.base); // pre-populated dest
// Non-integer -> FloatToInt returns false, but the negative-exponent block
- In
Convert.c:806:
Float v = FloatFrom(0u, &dbg.base);
Int r = IntFrom(424242u, &dbg.base); // pre-populated dest
bool ok = FloatToInt(&r, &v);- In
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
Compare.c:26:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(41, &alloc.base);
Int b = IntFrom(42, &alloc.base);
Int c = IntFromBinary("000101010", &alloc.base);- In
Compare.c:27:
Int a = IntFrom(41, &alloc.base);
Int b = IntFrom(42, &alloc.base);
Int c = IntFromBinary("000101010", &alloc.base);- In
Compare.c:28:
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
Compare.c:42:
bool test_int_compare_wrappers(void) {
WriteFmt("Testing Int compare wrappers\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Compare.c:46:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(41, &alloc.base);
Int b = IntFrom(42, &alloc.base);
Int c = IntFromBinary("000101010", &alloc.base);- In
Compare.c:47:
Int a = IntFrom(41, &alloc.base);
Int b = IntFrom(42, &alloc.base);
Int c = IntFromBinary("000101010", &alloc.base);- In
Compare.c:48:
Int a = IntFrom(41, &alloc.base);
Int b = IntFrom(42, &alloc.base);
Int c = IntFromBinary("000101010", &alloc.base);
bool result = IntLT(&a, &b);- In
Compare.c:71:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(42, &alloc.base);
Int same = IntFromBinary("00101010", &alloc.base);
Int big = IntFrom(1, &alloc.base);- In
Compare.c:72:
Int value = IntFrom(42, &alloc.base);
Int same = IntFromBinary("00101010", &alloc.base);
Int big = IntFrom(1, &alloc.base);- In
Compare.c:73:
Int value = IntFrom(42, &alloc.base);
Int same = IntFromBinary("00101010", &alloc.base);
Int big = IntFrom(1, &alloc.base);
IntShiftLeft(&big, 80);- In
Compare.c:102:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(42u, &alloc.base);
Int b = IntFromBinary("101010", &alloc.base);
Int c = IntFrom(0u, &alloc.base);- In
Compare.c:103:
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
Compare.c:104:
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
Compare.c:105:
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));- In
Compare.c:126:
DefaultAllocator alloc = DefaultAllocatorInit();
Int zero = IntFrom(0u, &alloc.base);
Int one = IntFrom(1u, &alloc.base);
Int small = IntFrom(42u, &alloc.base);- In
Compare.c:127:
Int zero = IntFrom(0u, &alloc.base);
Int one = IntFrom(1u, &alloc.base);
Int small = IntFrom(42u, &alloc.base);
Int large = IntFrom(1u, &alloc.base);- In
Compare.c:128:
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);- In
Compare.c:129:
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);- In
Compare.c:131:
Int large = IntFrom(1u, &alloc.base);
IntShiftLeft(&large, 80);
Int decimal = IntFromStr("12345678901234567890", &alloc.base);
u64 h_zero = int_hash(&zero, 0);- In
Compare.c:157:
// 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();- In
Compare.c:161:
DefaultAllocator alloc = DefaultAllocatorInit();
Map(Int, u64) counts = MapInit(int_hash, int_compare, &alloc);
Int k1 = IntFrom(100u, &alloc.base);- In
Compare.c:163:
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
- In
Compare.c:164:
Int k1 = IntFrom(100u, &alloc.base);
Int k2 = IntFrom(200u, &alloc.base);
Int k3 = IntFrom(100u, &alloc.base); // duplicate of k1 by value
- In
Compare.c:165:
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);- In
Compare.c:170:
MapInsertR(&counts, k2, 2u);
Int probe = IntFrom(100u, &alloc.base);
u64 *got = MapGetFirstPtr(&counts, probe);
Int missing = IntFrom(999u, &alloc.base);- In
Compare.c:172:
Int probe = IntFrom(100u, &alloc.base);
u64 *got = MapGetFirstPtr(&counts, probe);
Int missing = IntFrom(999u, &alloc.base);
u64 *gone = MapGetFirstPtr(&counts, missing);- In
Compare.c:205:
DefaultAllocator alloc = DefaultAllocatorInit();
Int lhs = IntFrom(0x8000000000000000u, &alloc.base);
bool fail = (IntBitLength(&lhs) != 64); // sanity: exactly 64 bits.
- In
Compare.c:222:
DefaultAllocator alloc = DefaultAllocatorInit();
Int lhs = IntFrom(7u, &alloc.base);
bool fail = (IntCompare(&lhs, 9u) != -1);- In
Compare.c:242:
DefaultAllocator alloc = DefaultAllocatorInit();
Int one = IntFrom(1, &alloc.base);
bool result = (IntIsOne(&one) == true);- In
Compare.c:263:
DefaultAllocator alloc = DefaultAllocatorInit();
Int zero = IntInit(&alloc.base);
int cmp = int_compare_i64(&zero, (i64)0);- In
Compare.c:269:
/* A non-zero lhs vs rhs 0 must still report greater (positive). */
Int five = IntFrom((u64)5u, &alloc.base);
result = result && (int_compare_i64(&five, (i64)0) > 0);- In
Compare.c:295:
int main(void) {
WriteFmt("[INFO] Starting Int.Compare tests\n\n");
TestFunction tests[] = {- In
Compare.c:316:
int total_tests = sizeof(tests) / sizeof(tests[0]);
int total_deadend_tests = sizeof(deadend_tests) / sizeof(deadend_tests[0]);
return run_test_suite(tests, total_tests, deadend_tests, total_deadend_tests, "Int.Compare");
}- In
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
Type.c:21:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntInit(&alloc.base);
bool result = IntIsZero(&value);- In
Type.c:36:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFromBinary("101101", &alloc.base);
IntClear(&value);- In
Type.c:53:
DefaultAllocator alloc = DefaultAllocatorInit();
Int original = IntFromBinary("1011", &alloc.base);
Int clone = IntClone(&original);- In
Type.c:54:
Int original = IntFromBinary("1011", &alloc.base);
Int clone = IntClone(&original);
bool result = IntEQ(&clone, &original);- In
Type.c:81:
alloc.base.retry_limit = 5;
Int original = IntInit(&alloc);
BitVecPush(&original.bits, true);- In
Type.c:87:
BitVecPush(&original.bits, true);
Int clone = IntClone(&original);
bool result =- In
Type.c:119:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(255, &alloc.base);
Int b = IntFrom(1, &alloc.base);
Int sum = IntInit(&alloc.base);- In
Type.c:120:
Int a = IntFrom(255, &alloc.base);
Int b = IntFrom(1, &alloc.base);
Int sum = IntInit(&alloc.base);- In
Type.c:121:
Int a = IntFrom(255, &alloc.base);
Int b = IntFrom(1, &alloc.base);
Int sum = IntInit(&alloc.base);
IntAdd(&sum, &a, &b);- In
Type.c:146:
DefaultAllocator alloc = DefaultAllocatorInit();
Int v255 = IntFrom(255, &alloc.base);
bool result = IntBitLength(&v255) == 8;- In
Type.c:157:
int main(void) {
WriteFmt("[INFO] Starting Int.Type tests\n\n");
TestFunction tests[] = {- In
Type.c:169:
int total_tests = sizeof(tests) / sizeof(tests[0]);
return run_test_suite(tests, total_tests, NULL, 0, "Int.Type");
}- In
Math.c:4:
#include <Misra/Std/Allocator/Debug.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Container/Int.h>
#include <Misra/Std/Log.h>
#include <Misra/Types.h>- In
Math.c:77:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(3, &alloc.base);
IntShiftLeft(&value, 4);- In
Math.c:94:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFromBinary("110000", &alloc.base);
IntShiftRight(&value, 4);- In
Math.c:111:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(255, &alloc.base);
Int b = IntFrom(1, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Math.c:112:
Int a = IntFrom(255, &alloc.base);
Int b = IntFrom(1, &alloc.base);
Int result_value = IntInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:113:
Int a = IntFrom(255, &alloc.base);
Int b = IntFrom(1, &alloc.base);
Int result_value = IntInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:135:
DefaultAllocator alloc = DefaultAllocatorInit();
Int base = IntFrom(40, &alloc.base);
Int rhs = IntFrom(2, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Math.c:136:
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
Math.c:137:
Int base = IntFrom(40, &alloc.base);
Int rhs = IntFrom(2, &alloc.base);
Int result_value = IntInit(&alloc.base);
Int huge = IntFromStr("123456789012345678901234567890", &alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:138:
Int rhs = IntFrom(2, &alloc.base);
Int result_value = IntInit(&alloc.base);
Int huge = IntFromStr("123456789012345678901234567890", &alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:168:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(256, &alloc.base);
Int b = IntFrom(1, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Math.c:169:
Int a = IntFrom(256, &alloc.base);
Int b = IntFrom(1, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Math.c:170:
Int a = IntFrom(256, &alloc.base);
Int b = IntFrom(1, &alloc.base);
Int result_value = IntInit(&alloc.base);
bool result = IntSub(&result_value, &a, &b);- In
Math.c:187:
DefaultAllocator alloc = DefaultAllocatorInit();
Int base = IntFrom(40, &alloc.base);
Int rhs = IntFrom(2, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Math.c:188:
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
Math.c:189:
Int base = IntFrom(40, &alloc.base);
Int rhs = IntFrom(2, &alloc.base);
Int result_value = IntInit(&alloc.base);
Int preserved = IntFrom(99, &alloc.base);
Int huge = IntFromStr("12345678901234567890", &alloc.base);- In
Math.c:190:
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
Math.c:191:
Int result_value = IntInit(&alloc.base);
Int preserved = IntFrom(99, &alloc.base);
Int huge = IntFromStr("12345678901234567890", &alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:225:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(3, &alloc.base);
Int b = IntFrom(5, &alloc.base);
Int result_value = IntFrom(99, &alloc.base);- In
Math.c:226:
Int a = IntFrom(3, &alloc.base);
Int b = IntFrom(5, &alloc.base);
Int result_value = IntFrom(99, &alloc.base);- In
Math.c:227:
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
Math.c:244:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(21, &alloc.base);
Int b = IntFrom(6, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Math.c:245:
Int a = IntFrom(21, &alloc.base);
Int b = IntFrom(6, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Math.c:246:
Int a = IntFrom(21, &alloc.base);
Int b = IntFrom(6, &alloc.base);
Int result_value = IntInit(&alloc.base);
IntMul(&result_value, &a, &b);- In
Math.c:264:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFromStr("12345678901234567890", &alloc.base);
Int result_value = IntInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:265:
Int value = IntFromStr("12345678901234567890", &alloc.base);
Int result_value = IntInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:285:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(0, &alloc.base);
Int b = IntFrom(12345, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Math.c:286:
Int a = IntFrom(0, &alloc.base);
Int b = IntFrom(12345, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Math.c:287:
Int a = IntFrom(0, &alloc.base);
Int b = IntFrom(12345, &alloc.base);
Int result_value = IntInit(&alloc.base);
IntMul(&result_value, &a, &b);- In
Math.c:306:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(12345, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Math.c:307:
Int value = IntFrom(12345, &alloc.base);
Int result_value = IntInit(&alloc.base);
IntSquare(&result_value, &value);- In
Math.c:324:
DefaultAllocator alloc = DefaultAllocatorInit();
Int base = IntFrom(7, &alloc.base);
Int exponent = IntFrom(20, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Math.c:325:
Int base = IntFrom(7, &alloc.base);
Int exponent = IntFrom(20, &alloc.base);
Int result_value = IntInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:326:
Int base = IntFrom(7, &alloc.base);
Int exponent = IntFrom(20, &alloc.base);
Int result_value = IntInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:351:
DefaultAllocator alloc = DefaultAllocatorInit();
Int dividend = IntFromStr("12345678901234567890", &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:352:
Int dividend = IntFromStr("12345678901234567890", &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
Str qtext = StrInit(&alloc.base);- In
Math.c:353:
Int dividend = IntFromStr("12345678901234567890", &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
Str qtext = StrInit(&alloc.base);- In
Math.c:375:
DefaultAllocator alloc = DefaultAllocatorInit();
Int dividend = IntFrom(126, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Math.c:376:
Int dividend = IntFrom(126, &alloc.base);
Int result_value = IntInit(&alloc.base);
IntDiv(&result_value, ÷nd, 10u);- In
Math.c:393:
DefaultAllocator alloc = DefaultAllocatorInit();
Int dividend = IntFromStr("12345678901234567890", &alloc.base);
Int result_value = IntInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:394:
Int dividend = IntFromStr("12345678901234567890", &alloc.base);
Int result_value = IntInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:413:
DefaultAllocator alloc = DefaultAllocatorInit();
Int dividend = IntFrom(10, &alloc.base);
Int divisor = IntFrom(3, &alloc.base);
Int result_value = IntFrom(99, &alloc.base);- In
Math.c:414:
Int dividend = IntFrom(10, &alloc.base);
Int divisor = IntFrom(3, &alloc.base);
Int result_value = IntFrom(99, &alloc.base);- In
Math.c:415:
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
Math.c:432:
DefaultAllocator alloc = DefaultAllocatorInit();
Int dividend = IntFromStr("12345678901234567890", &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:433:
Int dividend = IntFromStr("12345678901234567890", &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:434:
Int dividend = IntFromStr("12345678901234567890", &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:456:
DefaultAllocator alloc = DefaultAllocatorInit();
Int dividend = IntFrom(126, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Math.c:457:
Int dividend = IntFrom(126, &alloc.base);
Int result_value = IntInit(&alloc.base);
IntMod(&result_value, ÷nd, 10u);- In
Math.c:474:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFromStr("12345678901234567890", &alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:475:
Int value = IntFromStr("12345678901234567890", &alloc.base);
Int remainder = IntInit(&alloc.base);
IntMod(&remainder, &value, 97u);- In
Math.c:491:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(48, &alloc.base);
Int b = IntFrom(18, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Math.c:492:
Int a = IntFrom(48, &alloc.base);
Int b = IntFrom(18, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Math.c:493:
Int a = IntFrom(48, &alloc.base);
Int b = IntFrom(18, &alloc.base);
Int result_value = IntInit(&alloc.base);
IntGCD(&result_value, &a, &b);- In
Math.c:511:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(21, &alloc.base);
Int b = IntFrom(6, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Math.c:512:
Int a = IntFrom(21, &alloc.base);
Int b = IntFrom(6, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Math.c:513:
Int a = IntFrom(21, &alloc.base);
Int b = IntFrom(6, &alloc.base);
Int result_value = IntInit(&alloc.base);
IntLCM(&result_value, &a, &b);- In
Math.c:531:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(4096, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Math.c:532:
Int value = IntFrom(4096, &alloc.base);
Int result_value = IntInit(&alloc.base);
IntRoot(&result_value, &value, 4);- In
Math.c:549:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(200, &alloc.base);
Int root = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:550:
Int value = IntFrom(200, &alloc.base);
Int root = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:551:
Int value = IntFrom(200, &alloc.base);
Int root = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
IntRootRem(&root, &remainder, &value, 3);- In
Math.c:570:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(200, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Math.c:571:
Int value = IntFrom(200, &alloc.base);
Int result_value = IntInit(&alloc.base);
IntSqrt(&result_value, &value);- In
Math.c:588:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(200, &alloc.base);
Int root = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:589:
Int value = IntFrom(200, &alloc.base);
Int root = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:590:
Int value = IntFrom(200, &alloc.base);
Int root = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
IntSqrtRem(&root, &remainder, &value);- In
Math.c:609:
DefaultAllocator alloc = DefaultAllocatorInit();
Int square = IntFrom(144, &alloc.base);
Int non_square = IntFrom(145, &alloc.base);- In
Math.c:610:
Int square = IntFrom(144, &alloc.base);
Int non_square = IntFrom(145, &alloc.base);
bool result = IntIsPerfectSquare(&square);- In
Math.c:626:
DefaultAllocator alloc = DefaultAllocatorInit();
Int power = IntFrom(81, &alloc.base);
Int non_power = IntFrom(82, &alloc.base);
Int one = IntFrom(1, &alloc.base);- In
Math.c:627:
Int power = IntFrom(81, &alloc.base);
Int non_power = IntFrom(82, &alloc.base);
Int one = IntFrom(1, &alloc.base);- In
Math.c:628:
Int power = IntFrom(81, &alloc.base);
Int non_power = IntFrom(82, &alloc.base);
Int one = IntFrom(1, &alloc.base);
bool result = IntIsPerfectPower(&power);- In
Math.c:646:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(5, &alloc.base);
Int p = IntFrom(7, &alloc.base);
Int b = IntFrom(9, &alloc.base);- In
Math.c:647:
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
Math.c:648:
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
Math.c:649:
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
Math.c:667:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(12345, &alloc.base);
Int mod = IntFrom(97, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Math.c:668:
Int value = IntFrom(12345, &alloc.base);
Int mod = IntFrom(97, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Math.c:669:
Int value = IntFrom(12345, &alloc.base);
Int mod = IntFrom(97, &alloc.base);
Int result_value = IntInit(&alloc.base);
IntSquareMod(&result_value, &value, &mod);- In
Math.c:687:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(100, &alloc.base);
Int b = IntFrom(250, &alloc.base);
Int m = IntFrom(13, &alloc.base);- In
Math.c:688:
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
Math.c:689:
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
Math.c:690:
Int b = IntFrom(250, &alloc.base);
Int m = IntFrom(13, &alloc.base);
Int result_value = IntInit(&alloc.base);
IntModAdd(&result_value, &a, &b, &m);- In
Math.c:709:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(5, &alloc.base);
Int b = IntFrom(9, &alloc.base);
Int m = IntFrom(13, &alloc.base);- In
Math.c:710:
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
Math.c:711:
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
Math.c:712:
Int b = IntFrom(9, &alloc.base);
Int m = IntFrom(13, &alloc.base);
Int result_value = IntInit(&alloc.base);
IntModSub(&result_value, &a, &b, &m);- In
Math.c:731:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(123, &alloc.base);
Int b = IntFrom(456, &alloc.base);
Int m = IntFrom(97, &alloc.base);- In
Math.c:732:
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
Math.c:733:
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
Math.c:734:
Int b = IntFrom(456, &alloc.base);
Int m = IntFrom(97, &alloc.base);
Int result_value = IntInit(&alloc.base);
IntModMul(&result_value, &a, &b, &m);- In
Math.c:753:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(10, &alloc.base);
Int b = IntFrom(3, &alloc.base);
Int m = IntFrom(13, &alloc.base);- In
Math.c:754:
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
Math.c:755:
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
Math.c:756:
Int b = IntFrom(3, &alloc.base);
Int m = IntFrom(13, &alloc.base);
Int result_value = IntInit(&alloc.base);
Int check = IntInit(&alloc.base);- In
Math.c:757:
Int m = IntFrom(13, &alloc.base);
Int result_value = IntInit(&alloc.base);
Int check = IntInit(&alloc.base);
bool result = IntModDiv(&result_value, &a, &b, &m);- In
Math.c:779:
DefaultAllocator alloc = DefaultAllocatorInit();
Int base = IntFrom(7, &alloc.base);
Int mod = IntFrom(13, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Math.c:780:
Int base = IntFrom(7, &alloc.base);
Int mod = IntFrom(13, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Math.c:781:
Int base = IntFrom(7, &alloc.base);
Int mod = IntFrom(13, &alloc.base);
Int result_value = IntInit(&alloc.base);
IntPowMod(&result_value, &base, 20u, &mod);- In
Math.c:795:
bool test_int_pow_mod_integer_exponent(void) {
WriteFmt("Testing IntPowMod Int-exponent dispatch\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Math.c:799:
DefaultAllocator alloc = DefaultAllocatorInit();
Int base = IntFrom(4, &alloc.base);
Int exp = IntFrom(13, &alloc.base);
Int mod = IntFrom(497, &alloc.base);- In
Math.c:800:
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
Math.c:801:
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
Math.c:802:
Int exp = IntFrom(13, &alloc.base);
Int mod = IntFrom(497, &alloc.base);
Int result_value = IntInit(&alloc.base);
IntPowMod(&result_value, &base, &exp, &mod);- In
Math.c:821:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(3, &alloc.base);
Int mod = IntFrom(11, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Math.c:822:
Int value = IntFrom(3, &alloc.base);
Int mod = IntFrom(11, &alloc.base);
Int result_value = IntInit(&alloc.base);
Int check = IntInit(&alloc.base);- In
Math.c:823:
Int value = IntFrom(3, &alloc.base);
Int mod = IntFrom(11, &alloc.base);
Int result_value = IntInit(&alloc.base);
Int check = IntInit(&alloc.base);- In
Math.c:824:
Int mod = IntFrom(11, &alloc.base);
Int result_value = IntInit(&alloc.base);
Int check = IntInit(&alloc.base);
bool result = IntModInv(&result_value, &value, &mod);- In
Math.c:845:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(10, &alloc.base);
Int mod = IntFrom(13, &alloc.base);
Int root = IntInit(&alloc.base);- In
Math.c:846:
Int value = IntFrom(10, &alloc.base);
Int mod = IntFrom(13, &alloc.base);
Int root = IntInit(&alloc.base);
Int check = IntInit(&alloc.base);- In
Math.c:847:
Int value = IntFrom(10, &alloc.base);
Int mod = IntFrom(13, &alloc.base);
Int root = IntInit(&alloc.base);
Int check = IntInit(&alloc.base);- In
Math.c:848:
Int mod = IntFrom(13, &alloc.base);
Int root = IntInit(&alloc.base);
Int check = IntInit(&alloc.base);
bool result = IntModSqrt(&root, &value, &mod);- In
Math.c:867:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(3, &alloc.base);
Int mod = IntFrom(7, &alloc.base);
Int root = IntFrom(99, &alloc.base);- In
Math.c:868:
Int value = IntFrom(3, &alloc.base);
Int mod = IntFrom(7, &alloc.base);
Int root = IntFrom(99, &alloc.base);- In
Math.c:869:
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
Math.c:886:
DefaultAllocator alloc = DefaultAllocatorInit();
Int prime = IntFromStr("1000000007", &alloc.base);
Int composite = IntFrom(561, &alloc.base);- In
Math.c:887:
Int prime = IntFromStr("1000000007", &alloc.base);
Int composite = IntFrom(561, &alloc.base);
bool result = IntIsProbablePrime(&prime);- In
Math.c:903:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFromStr("1000000000", &alloc.base);
Int next = IntInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:904:
Int value = IntFromStr("1000000000", &alloc.base);
Int next = IntInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:924:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(6, &alloc.base);
Int mod = IntFrom(15, &alloc.base);
Int result_value = IntFrom(99, &alloc.base);- In
Math.c:925:
Int value = IntFrom(6, &alloc.base);
Int mod = IntFrom(15, &alloc.base);
Int result_value = IntFrom(99, &alloc.base);- In
Math.c:926:
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
Math.c:943:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(1, &alloc.base);
Int b = IntFrom(6, &alloc.base);
Int m = IntFrom(15, &alloc.base);- In
Math.c:944:
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
Math.c:945:
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
Math.c:946:
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
Math.c:964:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(1, &alloc.base);
Int b = IntFrom(2, &alloc.base);- In
Math.c:965:
Int a = IntFrom(1, &alloc.base);
Int b = IntFrom(2, &alloc.base);
IntAdd(NULL, &a, &b);- In
Math.c:983:
bool test_int_div_by_zero(void) {
WriteFmt("Testing Int division by zero handling\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Math.c:987:
DefaultAllocator alloc = DefaultAllocatorInit();
Int dividend = IntFrom(1, &alloc.base);
Int divisor = IntInit(&alloc.base);
Int quotient = IntFrom(99, &alloc.base);- In
Math.c:988:
Int dividend = IntFrom(1, &alloc.base);
Int divisor = IntInit(&alloc.base);
Int quotient = IntFrom(99, &alloc.base);
Int remainder = IntFrom(77, &alloc.base);- In
Math.c:989:
Int dividend = IntFrom(1, &alloc.base);
Int divisor = IntInit(&alloc.base);
Int quotient = IntFrom(99, &alloc.base);
Int remainder = IntFrom(77, &alloc.base);- In
Math.c:990:
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
Math.c:1010:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(16, &alloc.base);
Int root = IntFrom(99, &alloc.base);
Int remainder = IntFrom(77, &alloc.base);- In
Math.c:1011:
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
Math.c:1012:
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
Math.c:1030:
DefaultAllocator alloc = DefaultAllocatorInit();
Int dividend = IntFrom(10, &alloc.base);
Int quotient = IntFrom(99, &alloc.base);- In
Math.c:1031:
Int dividend = IntFrom(10, &alloc.base);
Int quotient = IntFrom(99, &alloc.base);
IntDiv("ient, ÷nd, 0u);- In
Math.c:1047:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(10, &alloc.base);
Int result_value = IntFrom(99, &alloc.base);- In
Math.c:1048:
Int value = IntFrom(10, &alloc.base);
Int result_value = IntFrom(99, &alloc.base);
IntMod(&result_value, &value, 0u);- In
Math.c:1064:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(10, &alloc.base);
Int b = IntFrom(3, &alloc.base);
Int m = IntInit(&alloc.base);- In
Math.c:1065:
Int a = IntFrom(10, &alloc.base);
Int b = IntFrom(3, &alloc.base);
Int m = IntInit(&alloc.base);
Int result_value = IntFrom(99, &alloc.base);- In
Math.c:1066:
Int a = IntFrom(10, &alloc.base);
Int b = IntFrom(3, &alloc.base);
Int m = IntInit(&alloc.base);
Int result_value = IntFrom(99, &alloc.base);- In
Math.c:1067:
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
Math.c:1085:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(3, &alloc.base);
Int n = IntFrom(8, &alloc.base);
int symbol = 99;- In
Math.c:1086:
Int a = IntFrom(3, &alloc.base);
Int n = IntFrom(8, &alloc.base);
int symbol = 99;
bool error = false;- In
Math.c:1106:
DefaultAllocator alloc = DefaultAllocatorInit();
Int base = IntFrom(2, &alloc.base);
Int mod = IntInit(&alloc.base);
Int result_value = IntInit(&alloc.base);- In
Math.c:1107:
Int base = IntFrom(2, &alloc.base);
Int mod = IntInit(&alloc.base);
Int result_value = IntInit(&alloc.base);- In
Math.c:1108:
Int base = IntFrom(2, &alloc.base);
Int mod = IntInit(&alloc.base);
Int result_value = IntInit(&alloc.base);
IntPowMod(&result_value, &base, 8u, &mod);- In
Math.c:1116:
bool test_int_pow_mod_integer_zero_modulus(void) {
WriteFmt("Testing IntPowMod Int-exponent zero modulus handling\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Math.c:1120:
DefaultAllocator alloc = DefaultAllocatorInit();
Int base = IntFrom(2, &alloc.base);
Int exp = IntFrom(8, &alloc.base);
Int mod = IntInit(&alloc.base);- In
Math.c:1121:
Int base = IntFrom(2, &alloc.base);
Int exp = IntFrom(8, &alloc.base);
Int mod = IntInit(&alloc.base);
Int result_value = IntFrom(99, &alloc.base);- In
Math.c:1122:
Int base = IntFrom(2, &alloc.base);
Int exp = IntFrom(8, &alloc.base);
Int mod = IntInit(&alloc.base);
Int result_value = IntFrom(99, &alloc.base);- In
Math.c:1123:
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
Math.c:1147:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(2, &alloc.base);
Int mod = IntFrom(7, &alloc.base);
Int root = IntFrom(99, &alloc.base);- In
Math.c:1148:
Int value = IntFrom(2, &alloc.base);
Int mod = IntFrom(7, &alloc.base);
Int root = IntFrom(99, &alloc.base);
Int check = IntInit(&alloc.base);- In
Math.c:1149:
Int value = IntFrom(2, &alloc.base);
Int mod = IntFrom(7, &alloc.base);
Int root = IntFrom(99, &alloc.base);
Int check = IntInit(&alloc.base);- In
Math.c:1150:
Int mod = IntFrom(7, &alloc.base);
Int root = IntFrom(99, &alloc.base);
Int check = IntInit(&alloc.base);
bool result = IntModSqrt(&root, &value, &mod);- In
Math.c:1178:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(3, &alloc.base);
Int mod = IntFrom(7, &alloc.base);
Int root = IntFrom(99, &alloc.base);- In
Math.c:1179:
Int value = IntFrom(3, &alloc.base);
Int mod = IntFrom(7, &alloc.base);
Int root = IntFrom(99, &alloc.base);- In
Math.c:1180:
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
Math.c:1204:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(2, &alloc.base);
Int mod = IntFrom(17, &alloc.base);
Int root = IntFrom(99, &alloc.base);- In
Math.c:1205:
Int value = IntFrom(2, &alloc.base);
Int mod = IntFrom(17, &alloc.base);
Int root = IntFrom(99, &alloc.base);
Int check = IntInit(&alloc.base);- In
Math.c:1206:
Int value = IntFrom(2, &alloc.base);
Int mod = IntFrom(17, &alloc.base);
Int root = IntFrom(99, &alloc.base);
Int check = IntInit(&alloc.base);- In
Math.c:1207:
Int mod = IntFrom(17, &alloc.base);
Int root = IntFrom(99, &alloc.base);
Int check = IntInit(&alloc.base);
bool result = IntModSqrt(&root, &value, &mod);- In
Math.c:1234:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(4, &alloc.base);
Int mod = IntFrom(17, &alloc.base);
Int root = IntFrom(99, &alloc.base);- In
Math.c:1235:
Int value = IntFrom(4, &alloc.base);
Int mod = IntFrom(17, &alloc.base);
Int root = IntFrom(99, &alloc.base);
Int check = IntInit(&alloc.base);- In
Math.c:1236:
Int value = IntFrom(4, &alloc.base);
Int mod = IntFrom(17, &alloc.base);
Int root = IntFrom(99, &alloc.base);
Int check = IntInit(&alloc.base);- In
Math.c:1237:
Int mod = IntFrom(17, &alloc.base);
Int root = IntFrom(99, &alloc.base);
Int check = IntInit(&alloc.base);
bool result = IntModSqrt(&root, &value, &mod);- In
Math.c:1264:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(3, &alloc.base);
Int mod = IntFrom(97, &alloc.base);
Int root = IntFrom(99, &alloc.base);- In
Math.c:1265:
Int value = IntFrom(3, &alloc.base);
Int mod = IntFrom(97, &alloc.base);
Int root = IntFrom(99, &alloc.base);
Int check = IntInit(&alloc.base);- In
Math.c:1266:
Int value = IntFrom(3, &alloc.base);
Int mod = IntFrom(97, &alloc.base);
Int root = IntFrom(99, &alloc.base);
Int check = IntInit(&alloc.base);- In
Math.c:1267:
Int mod = IntFrom(97, &alloc.base);
Int root = IntFrom(99, &alloc.base);
Int check = IntInit(&alloc.base);
bool result = IntModSqrt(&root, &value, &mod);- In
Math.c:1293:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(2, &alloc.base);
Int mod = IntFrom(257, &alloc.base);
Int root = IntFrom(99, &alloc.base);- In
Math.c:1294:
Int value = IntFrom(2, &alloc.base);
Int mod = IntFrom(257, &alloc.base);
Int root = IntFrom(99, &alloc.base);
Int check = IntInit(&alloc.base);- In
Math.c:1295:
Int value = IntFrom(2, &alloc.base);
Int mod = IntFrom(257, &alloc.base);
Int root = IntFrom(99, &alloc.base);
Int check = IntInit(&alloc.base);- In
Math.c:1296:
Int mod = IntFrom(257, &alloc.base);
Int root = IntFrom(99, &alloc.base);
Int check = IntInit(&alloc.base);
bool result = IntModSqrt(&root, &value, &mod);- In
Math.c:1319:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(10, &alloc.base);
Int mod = IntFrom(13, &alloc.base);
Int root = IntFrom(99, &alloc.base);- In
Math.c:1320:
Int value = IntFrom(10, &alloc.base);
Int mod = IntFrom(13, &alloc.base);
Int root = IntFrom(99, &alloc.base);
Int check = IntInit(&alloc.base);- In
Math.c:1321:
Int value = IntFrom(10, &alloc.base);
Int mod = IntFrom(13, &alloc.base);
Int root = IntFrom(99, &alloc.base);
Int check = IntInit(&alloc.base);- In
Math.c:1322:
Int mod = IntFrom(13, &alloc.base);
Int root = IntFrom(99, &alloc.base);
Int check = IntInit(&alloc.base);
bool result = IntModSqrt(&root, &value, &mod);- In
Math.c:1345:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(2, &alloc.base);
Int mod = IntFrom(13, &alloc.base);
Int root = IntFrom(99, &alloc.base);- In
Math.c:1346:
Int value = IntFrom(2, &alloc.base);
Int mod = IntFrom(13, &alloc.base);
Int root = IntFrom(99, &alloc.base);- In
Math.c:1347:
Int value = IntFrom(2, &alloc.base);
Int mod = IntFrom(13, &alloc.base);
Int root = IntFrom(99, &alloc.base);
bool result = !IntModSqrt(&root, &value, &mod);- In
Math.c:1368:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(0, &alloc.base);
Int mod = IntFrom(7, &alloc.base);
Int root = IntFrom(99, &alloc.base);- In
Math.c:1369:
Int value = IntFrom(0, &alloc.base);
Int mod = IntFrom(7, &alloc.base);
Int root = IntFrom(99, &alloc.base);- In
Math.c:1370:
Int value = IntFrom(0, &alloc.base);
Int mod = IntFrom(7, &alloc.base);
Int root = IntFrom(99, &alloc.base);
bool result = IntModSqrt(&root, &value, &mod);- In
Math.c:1391:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(21, &alloc.base);
Int mod = IntFrom(7, &alloc.base);
Int root = IntFrom(99, &alloc.base);- In
Math.c:1392:
Int value = IntFrom(21, &alloc.base);
Int mod = IntFrom(7, &alloc.base);
Int root = IntFrom(99, &alloc.base);- In
Math.c:1393:
Int value = IntFrom(21, &alloc.base);
Int mod = IntFrom(7, &alloc.base);
Int root = IntFrom(99, &alloc.base);
bool result = IntModSqrt(&root, &value, &mod);- In
Math.c:1415:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(5, &alloc.base);
Int mod = IntFrom(2, &alloc.base);
Int root = IntFrom(99, &alloc.base);- In
Math.c:1416:
Int value = IntFrom(5, &alloc.base);
Int mod = IntFrom(2, &alloc.base);
Int root = IntFrom(99, &alloc.base);- In
Math.c:1417:
Int value = IntFrom(5, &alloc.base);
Int mod = IntFrom(2, &alloc.base);
Int root = IntFrom(99, &alloc.base);
bool result = IntModSqrt(&root, &value, &mod);- In
Math.c:1438:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(1, &alloc.base);
Int mod = IntFrom(8, &alloc.base);
Int root = IntFrom(99, &alloc.base);- In
Math.c:1439:
Int value = IntFrom(1, &alloc.base);
Int mod = IntFrom(8, &alloc.base);
Int root = IntFrom(99, &alloc.base);- In
Math.c:1440:
Int value = IntFrom(1, &alloc.base);
Int mod = IntFrom(8, &alloc.base);
Int root = IntFrom(99, &alloc.base);
bool result = !IntModSqrt(&root, &value, &mod);- In
Math.c:1459:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(4, &alloc.base);
Int mod = IntFrom(9, &alloc.base);
Int root = IntFrom(99, &alloc.base);- In
Math.c:1460:
Int value = IntFrom(4, &alloc.base);
Int mod = IntFrom(9, &alloc.base);
Int root = IntFrom(99, &alloc.base);- In
Math.c:1461:
Int value = IntFrom(4, &alloc.base);
Int mod = IntFrom(9, &alloc.base);
Int root = IntFrom(99, &alloc.base);
bool result = !IntModSqrt(&root, &value, &mod);- In
Math.c:1481:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(4, &alloc.base);
Int mod = IntInit(&alloc.base);
Int root = IntFrom(99, &alloc.base);- In
Math.c:1482:
Int value = IntFrom(4, &alloc.base);
Int mod = IntInit(&alloc.base);
Int root = IntFrom(99, &alloc.base);- In
Math.c:1483:
Int value = IntFrom(4, &alloc.base);
Int mod = IntInit(&alloc.base);
Int root = IntFrom(99, &alloc.base);
bool result = !IntModSqrt(&root, &value, &mod);- In
Math.c:1505:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(23, &alloc.base);
Int mod = IntFrom(7, &alloc.base);
Int root = IntFrom(99, &alloc.base);- In
Math.c:1506:
Int value = IntFrom(23, &alloc.base);
Int mod = IntFrom(7, &alloc.base);
Int root = IntFrom(99, &alloc.base);
Int check = IntInit(&alloc.base);- In
Math.c:1507:
Int value = IntFrom(23, &alloc.base);
Int mod = IntFrom(7, &alloc.base);
Int root = IntFrom(99, &alloc.base);
Int check = IntInit(&alloc.base);- In
Math.c:1508:
Int mod = IntFrom(7, &alloc.base);
Int root = IntFrom(99, &alloc.base);
Int check = IntInit(&alloc.base);
bool result = IntModSqrt(&root, &value, &mod);- In
Math.c:1537:
/* 123456789 * 987654321 = 121932631112635269 */
Int a = IntFrom((u64)123456789u, &alloc.base);
Int b = IntFrom((u64)987654321u, &alloc.base);
Int product = IntInit(&alloc.base);- In
Math.c:1538:
/* 123456789 * 987654321 = 121932631112635269 */
Int a = IntFrom((u64)123456789u, &alloc.base);
Int b = IntFrom((u64)987654321u, &alloc.base);
Int product = IntInit(&alloc.base);- In
Math.c:1539:
Int a = IntFrom((u64)123456789u, &alloc.base);
Int b = IntFrom((u64)987654321u, &alloc.base);
Int product = IntInit(&alloc.base);
bool ok = IntMul(&product, &a, &b);- In
Math.c:1562:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom((u64)999u, &alloc.base);
Int zero = IntInit(&alloc.base);
Int product = IntInit(&alloc.base);- In
Math.c:1563:
Int a = IntFrom((u64)999u, &alloc.base);
Int zero = IntInit(&alloc.base);
Int product = IntInit(&alloc.base);- In
Math.c:1564:
Int a = IntFrom((u64)999u, &alloc.base);
Int zero = IntInit(&alloc.base);
Int product = IntInit(&alloc.base);
bool ok = IntMul(&product, &a, &zero);- In
Math.c:1590:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom((u64)2u, &alloc.base);
Int b = IntFrom((u64)3u, &alloc.base);- In
Math.c:1591:
Int a = IntFrom((u64)2u, &alloc.base);
Int b = IntFrom((u64)3u, &alloc.base);
IntMul(NULL, &a, &b);- In
Math.c:1604:
DefaultAllocator alloc = DefaultAllocatorInit();
Int base = IntFrom(7, &alloc.base);
Int result = IntInit(&alloc.base);- In
Math.c:1605:
Int base = IntFrom(7, &alloc.base);
Int result = IntInit(&alloc.base);
// exponent 0 -> 1 (loop body never runs)
- In
Math.c:1640:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(12, &alloc.base);
Int b = IntFrom(8, &alloc.base);- In
Math.c:1641:
Int a = IntFrom(12, &alloc.base);
Int b = IntFrom(8, &alloc.base);
IntGCD(NULL, &a, &b);- In
Math.c:1664:
DefaultAllocator alloc = DefaultAllocatorInit();
Int b = IntFrom(8, &alloc.base);
Int result = IntInit(&alloc.base);- In
Math.c:1665:
Int b = IntFrom(8, &alloc.base);
Int result = IntInit(&alloc.base);
IntGCD(&result, NULL, &b);- In
Math.c:1685:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(12, &alloc.base);
Int result = IntInit(&alloc.base);- In
Math.c:1686:
Int a = IntFrom(12, &alloc.base);
Int result = IntInit(&alloc.base);
IntGCD(&result, &a, NULL);- In
Math.c:1708:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(7, &alloc.base);
Int b = IntFrom(3, &alloc.base);
Int m = IntFrom(11, &alloc.base);- In
Math.c:1709:
Int a = IntFrom(7, &alloc.base);
Int b = IntFrom(3, &alloc.base);
Int m = IntFrom(11, &alloc.base);- In
Math.c:1710:
Int a = IntFrom(7, &alloc.base);
Int b = IntFrom(3, &alloc.base);
Int m = IntFrom(11, &alloc.base);
IntModAdd(NULL, &a, &b, &m);- In
Math.c:1735:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(3, &alloc.base);
Int b = IntFrom(5, &alloc.base);
Int mod = IntFrom(7, &alloc.base);- In
Math.c:1736:
Int a = IntFrom(3, &alloc.base);
Int b = IntFrom(5, &alloc.base);
Int mod = IntFrom(7, &alloc.base);- In
Math.c:1737:
Int a = IntFrom(3, &alloc.base);
Int b = IntFrom(5, &alloc.base);
Int mod = IntFrom(7, &alloc.base);
IntModMul(NULL, &a, &b, &mod);- In
Math.c:1761:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(4, &alloc.base);
Int b = IntFrom(1, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Math.c:1762:
Int a = IntFrom(4, &alloc.base);
Int b = IntFrom(1, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Math.c:1763:
Int a = IntFrom(4, &alloc.base);
Int b = IntFrom(1, &alloc.base);
Int result_value = IntInit(&alloc.base);
bool ok = IntSub(&result_value, &a, &b);- In
Math.c:1787:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(9, &alloc.base);
Int b = IntFrom(2, &alloc.base);- In
Math.c:1788:
Int a = IntFrom(9, &alloc.base);
Int b = IntFrom(2, &alloc.base);
int_sub(NULL, &a, &b);- In
Math.c:1806:
DefaultAllocator alloc = DefaultAllocatorInit();
Int dividend = IntFrom(100, &alloc.base);
int_div_u64_rem(NULL, ÷nd, 7);- In
Math.c:1823:
DefaultAllocator alloc = DefaultAllocatorInit();
Int quotient = IntInit(&alloc.base);
int_div_u64_rem("ient, NULL, 7);- In
Math.c:1843:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(0, &alloc.base);
Int b = IntFrom(5, &alloc.base);
Int result_value = IntFrom(99, &alloc.base);- In
Math.c:1844:
Int a = IntFrom(0, &alloc.base);
Int b = IntFrom(5, &alloc.base);
Int result_value = IntFrom(99, &alloc.base);- In
Math.c:1845:
Int a = IntFrom(0, &alloc.base);
Int b = IntFrom(5, &alloc.base);
Int result_value = IntFrom(99, &alloc.base);
bool result = IntLCM(&result_value, &a, &b);- In
Math.c:1875:
// 32 = 2^5: only perfect-power exponent in [2, max_degree] is the boundary
// value max_degree itself, so it distinguishes `<=` from `<`.
Int boundary = IntFrom(32, &alloc.base);
// 64 = 2^6 = 8^2 = 4^3 = 2^6: a perfect square found at degree 2, used as a
// sanity anchor so the test also exercises the common early-hit path.
- In
Math.c:1878:
// 64 = 2^6 = 8^2 = 4^3 = 2^6: a perfect square found at degree 2, used as a
// sanity anchor so the test also exercises the common early-hit path.
Int square_anchor = IntFrom(64, &alloc.base);
bool result = IntIsPerfectPower(&boundary);- In
Math.c:1905:
DefaultAllocator alloc = DefaultAllocatorInit();
Int dividend = IntFrom(12, &alloc.base);
Int divisor = IntFrom(4, &alloc.base);- In
Math.c:1906:
Int dividend = IntFrom(12, &alloc.base);
Int divisor = IntFrom(4, &alloc.base);
IntDivExact(NULL, ÷nd, &divisor);- In
Math.c:1925:
DefaultAllocator alloc = DefaultAllocatorInit();
Int ones = IntFromBinary("1111111", &alloc.base); // 127
Int one = IntFrom(1u, &alloc.base);
Int sum = IntInit(&alloc.base);- In
Math.c:1926:
Int ones = IntFromBinary("1111111", &alloc.base); // 127
Int one = IntFrom(1u, &alloc.base);
Int sum = IntInit(&alloc.base);- In
Math.c:1927:
Int ones = IntFromBinary("1111111", &alloc.base); // 127
Int one = IntFrom(1u, &alloc.base);
Int sum = IntInit(&alloc.base);
IntAdd(&sum, &ones, &one);- In
Math.c:1951:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(0, &alloc.base);
Int root = IntFrom(99, &alloc.base);
Int remainder = IntFrom(77, &alloc.base);- In
Math.c:1952:
Int value = IntFrom(0, &alloc.base);
Int root = IntFrom(99, &alloc.base);
Int remainder = IntFrom(77, &alloc.base);- In
Math.c:1953:
Int value = IntFrom(0, &alloc.base);
Int root = IntFrom(99, &alloc.base);
Int remainder = IntFrom(77, &alloc.base);
bool ok = IntRootRem(&root, &remainder, &value, 3);- In
Math.c:1976:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(10000, &alloc.base);
Int root = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:1977:
Int value = IntFrom(10000, &alloc.base);
Int root = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:1978:
Int value = IntFrom(10000, &alloc.base);
Int root = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
bool ok = IntRootRem(&root, &remainder, &value, 2);- In
Math.c:1999:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(1000, &alloc.base);
Int root = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:2000:
Int value = IntFrom(1000, &alloc.base);
Int root = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:2001:
Int value = IntFrom(1000, &alloc.base);
Int root = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
bool ok = IntRootRem(&root, &remainder, &value, 3);- In
Math.c:2023:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(1001, &alloc.base);
Int root = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:2024:
Int value = IntFrom(1001, &alloc.base);
Int root = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:2025:
Int value = IntFrom(1001, &alloc.base);
Int root = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
bool ok = IntRootRem(&root, &remainder, &value, 3);- In
Math.c:2046:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(999, &alloc.base);
Int root = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:2047:
Int value = IntFrom(999, &alloc.base);
Int root = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:2048:
Int value = IntFrom(999, &alloc.base);
Int root = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
bool ok = IntRootRem(&root, &remainder, &value, 3);- In
Math.c:2069:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(1000000, &alloc.base);
Int root = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:2070:
Int value = IntFrom(1000000, &alloc.base);
Int root = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:2071:
Int value = IntFrom(1000000, &alloc.base);
Int root = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
bool ok = IntRootRem(&root, &remainder, &value, 4);- In
Math.c:2096:
// exponent the real code must take the int_pow_u64 path and return true.
bool test_m22_pow_int_exponent_value(void) {
WriteFmt("Testing IntPow with an Int exponent (small, exact value)\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Math.c:2100:
DefaultAllocator alloc = DefaultAllocatorInit();
Int base = IntFrom(7, &alloc.base);
Int exp = IntFrom(5, &alloc.base);
Int power = IntInit(&alloc.base);- In
Math.c:2101:
Int base = IntFrom(7, &alloc.base);
Int exp = IntFrom(5, &alloc.base);
Int power = IntInit(&alloc.base);- In
Math.c:2102:
Int base = IntFrom(7, &alloc.base);
Int exp = IntFrom(5, &alloc.base);
Int power = IntInit(&alloc.base);
// 7**5 == 16807.
- In
Math.c:2126:
DefaultAllocator alloc = DefaultAllocatorInit();
Int base = IntFrom(2, &alloc.base);
// 2**64 == 18446744073709551616 -> bit length 65, does not fit u64.
Int exp = IntFromStr("18446744073709551616", &alloc.base);- In
Math.c:2128:
Int base = IntFrom(2, &alloc.base);
// 2**64 == 18446744073709551616 -> bit length 65, does not fit u64.
Int exp = IntFromStr("18446744073709551616", &alloc.base);
Int power = IntFrom(123, &alloc.base);
Int sentinel = IntFrom(123, &alloc.base);- In
Math.c:2129:
// 2**64 == 18446744073709551616 -> bit length 65, does not fit u64.
Int exp = IntFromStr("18446744073709551616", &alloc.base);
Int power = IntFrom(123, &alloc.base);
Int sentinel = IntFrom(123, &alloc.base);- In
Math.c:2130:
Int exp = IntFromStr("18446744073709551616", &alloc.base);
Int power = IntFrom(123, &alloc.base);
Int sentinel = IntFrom(123, &alloc.base);
bool rejected = !IntPow(&power, &base, &exp);- In
Math.c:2158:
DefaultAllocator alloc = DefaultAllocatorInit();
Int dividend = IntFrom(1000, &alloc.base);
Int quotient = IntInit(&alloc.base);- In
Math.c:2159:
Int dividend = IntFrom(1000, &alloc.base);
Int quotient = IntInit(&alloc.base);
// 1000 / 7 == 142 (floor).
- In
Math.c:2181:
DefaultAllocator alloc = DefaultAllocatorInit();
Int dividend = IntFrom(1000, &alloc.base);
Int quotient = IntFrom(55, &alloc.base);- In
Math.c:2182:
Int dividend = IntFrom(1000, &alloc.base);
Int quotient = IntFrom(55, &alloc.base);
bool failed = !IntDiv("ient, ÷nd, (i64)-7);- In
Math.c:2204:
DefaultAllocator alloc = DefaultAllocatorInit();
Int dividend = IntFrom(1001, &alloc.base);
Int quotient = IntInit(&alloc.base);- In
Math.c:2205:
Int dividend = IntFrom(1001, &alloc.base);
Int quotient = IntInit(&alloc.base);
// 1001 / 7 == 143 exactly.
- In
Math.c:2225:
DefaultAllocator alloc = DefaultAllocatorInit();
Int dividend = IntFrom(1001, &alloc.base);
Int quotient = IntFrom(55, &alloc.base);- In
Math.c:2226:
Int dividend = IntFrom(1001, &alloc.base);
Int quotient = IntFrom(55, &alloc.base);
bool failed = !IntDivExact("ient, ÷nd, (i64)-7);- In
Math.c:2256:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(5u, &alloc.base);
bool fail = (IntCompare(&value, 5u) != 0);- In
Math.c:2274:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(1u, &alloc.base);
bool fail = (IntCompare(&value, 1u) != 0);- In
Math.c:2298:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(7, &alloc.base);
Int result_value = IntFrom(99, &alloc.base);- In
Math.c:2299:
Int value = IntFrom(7, &alloc.base);
Int result_value = IntFrom(99, &alloc.base);
/* Signed literal forces int_mul_i64 dispatch. */- In
Math.c:2323:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(123, &alloc.base);
Int result_value = IntFrom(99, &alloc.base);- In
Math.c:2324:
Int value = IntFrom(123, &alloc.base);
Int result_value = IntFrom(99, &alloc.base);
bool ok = IntMul(&result_value, &value, (i64)0);- In
Math.c:2348:
DefaultAllocator alloc = DefaultAllocatorInit();
Int base = IntFrom(3, &alloc.base);
Int result_value = IntFrom(99, &alloc.base);- In
Math.c:2349:
Int base = IntFrom(3, &alloc.base);
Int result_value = IntFrom(99, &alloc.base);
bool ok = IntPow(&result_value, &base, (i64)4);- In
Math.c:2372:
DefaultAllocator alloc = DefaultAllocatorInit();
Int base = IntFrom(7, &alloc.base);
Int result_value = IntFrom(99, &alloc.base);- In
Math.c:2373:
Int base = IntFrom(7, &alloc.base);
Int result_value = IntFrom(99, &alloc.base);
bool ok = IntPow(&result_value, &base, (i64)0);- In
Math.c:2396:
DefaultAllocator alloc = DefaultAllocatorInit();
Int dividend = IntFrom(100, &alloc.base);
Int result_value = IntFrom(99, &alloc.base);- In
Math.c:2397:
Int dividend = IntFrom(100, &alloc.base);
Int result_value = IntFrom(99, &alloc.base);
/* Unsigned literal forces int_div_u64 dispatch. */- In
Math.c:2420:
DefaultAllocator alloc = DefaultAllocatorInit();
Int dividend = IntFrom(123456789, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Math.c:2421:
Int dividend = IntFrom(123456789, &alloc.base);
Int result_value = IntInit(&alloc.base);
bool ok = int_div_exact_u64(&result_value, ÷nd, 3u);- In
Math.c:2444:
DefaultAllocator alloc = DefaultAllocatorInit();
Int dividend = IntFromStr("12345678901234567890", &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:2445:
Int dividend = IntFromStr("12345678901234567890", &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
Str qtext = StrInit(&alloc.base);- In
Math.c:2446:
Int dividend = IntFromStr("12345678901234567890", &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
Str qtext = StrInit(&alloc.base);- In
Math.c:2474:
DefaultAllocator alloc = DefaultAllocatorInit();
Int dividend = IntFromStr("12345678901234567890", &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:2475:
Int dividend = IntFromStr("12345678901234567890", &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
Str qtext = StrInit(&alloc.base);- In
Math.c:2476:
Int dividend = IntFromStr("12345678901234567890", &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
Str qtext = StrInit(&alloc.base);- In
Math.c:2506:
DefaultAllocator alloc = DefaultAllocatorInit();
Int dividend = IntFromStr("12345678901234567890", &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Math.c:2507:
Int dividend = IntFromStr("12345678901234567890", &alloc.base);
Int result_value = IntInit(&alloc.base);
bool ok = int_mod_i64_into(&result_value, ÷nd, (i64)13);- In
Math.c:2533:
DefaultAllocator alloc = DefaultAllocatorInit();
Int base = IntFrom(7, &alloc.base);
Int modulus = IntFrom(1000000007, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Math.c:2534:
Int base = IntFrom(7, &alloc.base);
Int modulus = IntFrom(1000000007, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Math.c:2535:
Int base = IntFrom(7, &alloc.base);
Int modulus = IntFrom(1000000007, &alloc.base);
Int result_value = IntInit(&alloc.base);
bool ok = int_pow_i64_mod(&result_value, &base, (i64)13, &modulus);- In
Math.c:2560:
DefaultAllocator alloc = DefaultAllocatorInit();
Int base = IntFrom(7, &alloc.base);
Int modulus = IntFrom(1000000007, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Math.c:2561:
Int base = IntFrom(7, &alloc.base);
Int modulus = IntFrom(1000000007, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Math.c:2562:
Int base = IntFrom(7, &alloc.base);
Int modulus = IntFrom(1000000007, &alloc.base);
Int result_value = IntInit(&alloc.base);
bool ok = int_pow_i64_mod(&result_value, &base, (i64)0, &modulus);- In
Math.c:2585:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(4096, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Math.c:2586:
Int value = IntFrom(4096, &alloc.base);
Int result_value = IntInit(&alloc.base);
bool ok = IntRoot(&result_value, &value, 4);- In
Math.c:2612:
DefaultAllocator alloc = DefaultAllocatorInit();
Int zero = IntInit(&alloc.base);
bool result = (IntIsOdd(&zero) == false);- In
Math.c:2633:
DefaultAllocator alloc = DefaultAllocatorInit();
Int dividend = IntFrom((u64)100u, &alloc.base);
Int result = IntInit(&alloc.base);- In
Math.c:2634:
Int dividend = IntFrom((u64)100u, &alloc.base);
Int result = IntInit(&alloc.base);
bool ok = IntMod(&result, ÷nd, (unsigned long)7u);- In
Math.c:2651:
///
static bool test_m28_trailing_zero_invalid_deadend(void) {
WriteFmt("Testing IntTrailingZeroCount validation on invalid Int\n");
Int invalid = {0};- In
Math.c:2653:
WriteFmt("Testing IntTrailingZeroCount validation on invalid Int\n");
Int invalid = {0};
(void)IntTrailingZeroCount(&invalid);- In
Math.c:2673:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(2, &alloc.base);
Int n_odd = IntFrom(7, &alloc.base);
Int n_even = IntFrom(8, &alloc.base);- In
Math.c:2674:
Int a = IntFrom(2, &alloc.base);
Int n_odd = IntFrom(7, &alloc.base);
Int n_even = IntFrom(8, &alloc.base);- In
Math.c:2675:
Int a = IntFrom(2, &alloc.base);
Int n_odd = IntFrom(7, &alloc.base);
Int n_even = IntFrom(8, &alloc.base);
bool err_ok = true;- In
Math.c:2708:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(3, &alloc.base);
Int mod = IntFrom(11, &alloc.base);
Int result = IntInit(&alloc.base);- In
Math.c:2709:
Int value = IntFrom(3, &alloc.base);
Int mod = IntFrom(11, &alloc.base);
Int result = IntInit(&alloc.base);
Int check = IntInit(&alloc.base);- In
Math.c:2710:
Int value = IntFrom(3, &alloc.base);
Int mod = IntFrom(11, &alloc.base);
Int result = IntInit(&alloc.base);
Int check = IntInit(&alloc.base);- In
Math.c:2711:
Int mod = IntFrom(11, &alloc.base);
Int result = IntInit(&alloc.base);
Int check = IntInit(&alloc.base);
bool ok = IntModInv(&result, &value, &mod);- In
Math.c:2742:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(5, &alloc.base);
Int mod = IntFrom(11, &alloc.base);
Int result = IntInit(&alloc.base);- In
Math.c:2743:
Int value = IntFrom(5, &alloc.base);
Int mod = IntFrom(11, &alloc.base);
Int result = IntInit(&alloc.base);
Int check = IntInit(&alloc.base);- In
Math.c:2744:
Int value = IntFrom(5, &alloc.base);
Int mod = IntFrom(11, &alloc.base);
Int result = IntInit(&alloc.base);
Int check = IntInit(&alloc.base);- In
Math.c:2745:
Int mod = IntFrom(11, &alloc.base);
Int result = IntInit(&alloc.base);
Int check = IntInit(&alloc.base);
bool ok = IntModInv(&result, &value, &mod);- In
Math.c:2774:
DefaultAllocator alloc = DefaultAllocatorInit();
Int dividend = IntFrom(10, &alloc.base);
Int quotient = IntFrom(99, &alloc.base);- In
Math.c:2775:
Int dividend = IntFrom(10, &alloc.base);
Int quotient = IntFrom(99, &alloc.base);
bool ok = IntDiv("ient, ÷nd, 0u);- In
Math.c:2792:
DefaultAllocator alloc = DefaultAllocatorInit();
Int dividend = IntFrom(10, &alloc.base);
Int quotient = IntFrom(99, &alloc.base);- In
Math.c:2793:
Int dividend = IntFrom(10, &alloc.base);
Int quotient = IntFrom(99, &alloc.base);
bool ok = IntDiv("ient, ÷nd, (i64)0);- In
Math.c:2814:
DefaultAllocator alloc = DefaultAllocatorInit();
Int dividend = IntFrom(127, &alloc.base);
Int quotient = IntInit(&alloc.base);- In
Math.c:2815:
Int dividend = IntFrom(127, &alloc.base);
Int quotient = IntInit(&alloc.base);
bool ok = IntDivExact("ient, ÷nd, 10u);- In
Math.c:2831:
DefaultAllocator alloc = DefaultAllocatorInit();
Int dividend = IntFrom(127, &alloc.base);
Int quotient = IntInit(&alloc.base);- In
Math.c:2832:
Int dividend = IntFrom(127, &alloc.base);
Int quotient = IntInit(&alloc.base);
bool ok = IntDivExact("ient, ÷nd, (i64)10);- In
Math.c:2851:
DefaultAllocator alloc = DefaultAllocatorInit();
Int dividend = IntFrom(127, &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:2852:
Int dividend = IntFrom(127, &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:2853:
Int dividend = IntFrom(127, &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
bool ok = IntDivMod("ient, &remainder, ÷nd, 0u);- In
Math.c:2870:
DefaultAllocator alloc = DefaultAllocatorInit();
Int dividend = IntFrom(127, &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:2871:
Int dividend = IntFrom(127, &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:2872:
Int dividend = IntFrom(127, &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
bool ok = IntDivMod("ient, &remainder, ÷nd, (i64)0);- In
Math.c:2892:
DefaultAllocator alloc = DefaultAllocatorInit();
Int dividend = IntFrom(127, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Math.c:2893:
Int dividend = IntFrom(127, &alloc.base);
Int result_value = IntInit(&alloc.base);
bool ok = IntMod(&result_value, ÷nd, 0u);- In
Math.c:2909:
DefaultAllocator alloc = DefaultAllocatorInit();
Int dividend = IntFrom(127, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Math.c:2910:
Int dividend = IntFrom(127, &alloc.base);
Int result_value = IntInit(&alloc.base);
bool ok = IntMod(&result_value, ÷nd, (i64)0);- In
Math.c:2932:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(1, &alloc.base);
IntShiftLeft(&value, 50); // 2^50
- In
Math.c:2935:
IntShiftLeft(&value, 50); // 2^50
Int root = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:2936:
Int root = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
bool ok = IntSqrtRem(&root, &remainder, &value);- In
Math.c:2958:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(3, &alloc.base);
Int n = IntFrom(7, &alloc.base);- In
Math.c:2959:
Int a = IntFrom(3, &alloc.base);
Int n = IntFrom(7, &alloc.base);
int symbol = 99;- In
Math.c:2982:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(2, &alloc.base);
Int mod = IntFrom(17, &alloc.base);
Int root = IntInit(&alloc.base);- In
Math.c:2983:
Int value = IntFrom(2, &alloc.base);
Int mod = IntFrom(17, &alloc.base);
Int root = IntInit(&alloc.base);
Int check = IntInit(&alloc.base);- In
Math.c:2984:
Int value = IntFrom(2, &alloc.base);
Int mod = IntFrom(17, &alloc.base);
Int root = IntInit(&alloc.base);
Int check = IntInit(&alloc.base);- In
Math.c:2985:
Int mod = IntFrom(17, &alloc.base);
Int root = IntInit(&alloc.base);
Int check = IntInit(&alloc.base);
bool ok = IntModSqrt(&root, &value, &mod);- In
Math.c:3004:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(1, &alloc.base);
bool result = !IntIsProbablePrime(&value);- In
Math.c:3018:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(2, &alloc.base);
bool result = IntIsProbablePrime(&value);- In
Math.c:3032:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(4, &alloc.base);
bool result = !IntIsProbablePrime(&value);- In
Math.c:3046:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(3, &alloc.base);
bool result = IntIsProbablePrime(&value);- In
Math.c:3060:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(97, &alloc.base);
bool result = IntIsProbablePrime(&value);- In
Math.c:3074:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(561, &alloc.base);
bool result = !IntIsProbablePrime(&value);- In
Math.c:3088:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(1763, &alloc.base);
bool result = !IntIsProbablePrime(&value);- In
Math.c:3102:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFromStr("1373653", &alloc.base);
bool result = !IntIsProbablePrime(&value);- In
Math.c:3116:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFromStr("1000000007", &alloc.base);
bool result = IntIsProbablePrime(&value);- In
Math.c:3130:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(97, &alloc.base);
bool error = true;- In
Math.c:3152:
DefaultAllocator alloc = DefaultAllocatorInit();
Int dividend = IntFromStr("12345678901234567890123456789", &alloc.base);
Int divisor = IntFromStr("987654321987654321", &alloc.base);
Int quotient = IntInit(&alloc.base);- In
Math.c:3153:
Int dividend = IntFromStr("12345678901234567890123456789", &alloc.base);
Int divisor = IntFromStr("987654321987654321", &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:3154:
Int dividend = IntFromStr("12345678901234567890123456789", &alloc.base);
Int divisor = IntFromStr("987654321987654321", &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:3155:
Int divisor = IntFromStr("987654321987654321", &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
bool ok = int_div_mod("ient, &remainder, ÷nd, &divisor);- In
Math.c:3187:
DefaultAllocator alloc = DefaultAllocatorInit();
Int dividend = IntFromStr("1000000007", &alloc.base);
Int divisor = IntFromStr("97", &alloc.base);
Int quotient = IntInit(&alloc.base);- In
Math.c:3188:
Int dividend = IntFromStr("1000000007", &alloc.base);
Int divisor = IntFromStr("97", &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:3189:
Int dividend = IntFromStr("1000000007", &alloc.base);
Int divisor = IntFromStr("97", &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:3190:
Int divisor = IntFromStr("97", &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
bool ok = int_div_mod("ient, &remainder, ÷nd, &divisor);- In
Math.c:3216:
DefaultAllocator alloc = DefaultAllocatorInit();
Int dividend = IntFromStr("11975308533", &alloc.base);
Int divisor = IntFromStr("97", &alloc.base);
Int quotient = IntInit(&alloc.base);- In
Math.c:3217:
Int dividend = IntFromStr("11975308533", &alloc.base);
Int divisor = IntFromStr("97", &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:3218:
Int dividend = IntFromStr("11975308533", &alloc.base);
Int divisor = IntFromStr("97", &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:3219:
Int divisor = IntFromStr("97", &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
bool ok = int_div_mod("ient, &remainder, ÷nd, &divisor);- In
Math.c:3244:
DefaultAllocator alloc = DefaultAllocatorInit();
Int dividend = IntFromStr("42", &alloc.base);
Int divisor = IntFromStr("1000", &alloc.base);
Int quotient = IntInit(&alloc.base);- In
Math.c:3245:
Int dividend = IntFromStr("42", &alloc.base);
Int divisor = IntFromStr("1000", &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:3246:
Int dividend = IntFromStr("42", &alloc.base);
Int divisor = IntFromStr("1000", &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:3247:
Int divisor = IntFromStr("1000", &alloc.base);
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
bool ok = int_div_mod("ient, &remainder, ÷nd, &divisor);- In
Math.c:3272:
DefaultAllocator alloc = DefaultAllocatorInit();
Int dividend = IntFromStr("12345", &alloc.base);
Int divisor = IntInit(&alloc.base); /* zero */
Int quotient = IntInit(&alloc.base);- In
Math.c:3274:
Int dividend = IntFromStr("12345", &alloc.base);
Int divisor = IntInit(&alloc.base); /* zero */
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:3275:
Int divisor = IntInit(&alloc.base); /* zero */
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
bool ok = int_div_mod("ient, &remainder, ÷nd, &divisor);- In
Math.c:3297:
DefaultAllocator alloc = DefaultAllocatorInit();
Int dividend = IntFromStr("100", &alloc.base);
Int divisor = IntFromStr("7", &alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:3298:
Int dividend = IntFromStr("100", &alloc.base);
Int divisor = IntFromStr("7", &alloc.base);
Int remainder = IntInit(&alloc.base);- In
Math.c:3299:
Int dividend = IntFromStr("100", &alloc.base);
Int divisor = IntFromStr("7", &alloc.base);
Int remainder = IntInit(&alloc.base);
/* Must abort inside int_div_mod via ValidateInt(quotient). */- In
Math.c:3319:
DefaultAllocator alloc = DefaultAllocatorInit();
Int dividend = IntFromStr("100", &alloc.base);
Int divisor = IntFromStr("7", &alloc.base);
Int quotient = IntInit(&alloc.base);- In
Math.c:3320:
Int dividend = IntFromStr("100", &alloc.base);
Int divisor = IntFromStr("7", &alloc.base);
Int quotient = IntInit(&alloc.base);- In
Math.c:3321:
Int dividend = IntFromStr("100", &alloc.base);
Int divisor = IntFromStr("7", &alloc.base);
Int quotient = IntInit(&alloc.base);
/* Must abort inside int_div_mod via ValidateInt(remainder). */- In
Math.c:3338:
DefaultAllocator alloc = DefaultAllocatorInit();
Int base = IntFrom(7, &alloc.base);
Int exp = IntFrom(0, &alloc.base);
Int mod = IntFrom(1, &alloc.base);- In
Math.c:3339:
Int base = IntFrom(7, &alloc.base);
Int exp = IntFrom(0, &alloc.base);
Int mod = IntFrom(1, &alloc.base);
Int result_value = IntFrom(99, &alloc.base);- In
Math.c:3340:
Int base = IntFrom(7, &alloc.base);
Int exp = IntFrom(0, &alloc.base);
Int mod = IntFrom(1, &alloc.base);
Int result_value = IntFrom(99, &alloc.base);- In
Math.c:3341:
Int exp = IntFrom(0, &alloc.base);
Int mod = IntFrom(1, &alloc.base);
Int result_value = IntFrom(99, &alloc.base);
bool ok = int_pow_mod(&result_value, &base, &exp, &mod);- In
Math.c:3359:
DefaultAllocator alloc = DefaultAllocatorInit();
Int base = IntFrom(123456, &alloc.base);
Int exp = IntFrom(11, &alloc.base);
Int mod = IntFrom(1, &alloc.base);- In
Math.c:3360:
Int base = IntFrom(123456, &alloc.base);
Int exp = IntFrom(11, &alloc.base);
Int mod = IntFrom(1, &alloc.base);
Int result_value = IntFrom(42, &alloc.base);- In
Math.c:3361:
Int base = IntFrom(123456, &alloc.base);
Int exp = IntFrom(11, &alloc.base);
Int mod = IntFrom(1, &alloc.base);
Int result_value = IntFrom(42, &alloc.base);- In
Math.c:3362:
Int exp = IntFrom(11, &alloc.base);
Int mod = IntFrom(1, &alloc.base);
Int result_value = IntFrom(42, &alloc.base);
bool ok = int_pow_mod(&result_value, &base, &exp, &mod);- In
Math.c:3380:
DefaultAllocator alloc = DefaultAllocatorInit();
Int base = IntFrom(3, &alloc.base);
Int exp = IntFrom(13, &alloc.base);
Int mod = IntFrom(497, &alloc.base);- In
Math.c:3381:
Int base = IntFrom(3, &alloc.base);
Int exp = IntFrom(13, &alloc.base);
Int mod = IntFrom(497, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Math.c:3382:
Int base = IntFrom(3, &alloc.base);
Int exp = IntFrom(13, &alloc.base);
Int mod = IntFrom(497, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Math.c:3383:
Int exp = IntFrom(13, &alloc.base);
Int mod = IntFrom(497, &alloc.base);
Int result_value = IntInit(&alloc.base);
bool ok = int_pow_mod(&result_value, &base, &exp, &mod);- In
Math.c:3401:
DebugAllocator dbg = DebugAllocatorInit();
Int base = IntFrom(123456789u, &dbg.base);
Int exp = IntFrom(987654321u, &dbg.base); // many set bits + bits
Int mod = IntFrom(1000000007u, &dbg.base);- In
Math.c:3402:
Int base = IntFrom(123456789u, &dbg.base);
Int exp = IntFrom(987654321u, &dbg.base); // many set bits + bits
Int mod = IntFrom(1000000007u, &dbg.base);
Int result_value = IntInit(&dbg.base);- In
Math.c:3403:
Int base = IntFrom(123456789u, &dbg.base);
Int exp = IntFrom(987654321u, &dbg.base); // many set bits + bits
Int mod = IntFrom(1000000007u, &dbg.base);
Int result_value = IntInit(&dbg.base);- In
Math.c:3404:
Int exp = IntFrom(987654321u, &dbg.base); // many set bits + bits
Int mod = IntFrom(1000000007u, &dbg.base);
Int result_value = IntInit(&dbg.base);
bool ok = int_pow_mod(&result_value, &base, &exp, &mod);- In
Math.c:3433:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(0, &alloc.base);
Int next = IntInit(&alloc.base);- In
Math.c:3434:
Int value = IntFrom(0, &alloc.base);
Int next = IntInit(&alloc.base);
bool ok = IntNextPrime(&next, &value);- In
Math.c:3461:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(10, &alloc.base);
Int next = IntInit(&alloc.base);- In
Math.c:3462:
Int value = IntFrom(10, &alloc.base);
Int next = IntInit(&alloc.base);
bool ok = IntNextPrime(&next, &value);- In
Math.c:3484:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(9, &alloc.base);
Int next = IntInit(&alloc.base);- In
Math.c:3485:
Int value = IntFrom(9, &alloc.base);
Int next = IntInit(&alloc.base);
bool ok = IntNextPrime(&next, &value);- In
Math.c:3508:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(10, &alloc.base);
(void)IntNextPrime(NULL, &value);- In
Math.c:3527:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(9, &alloc.base);
Int b = IntFrom(5, &alloc.base);
Int m = IntFrom(13, &alloc.base);- In
Math.c:3528:
Int a = IntFrom(9, &alloc.base);
Int b = IntFrom(5, &alloc.base);
Int m = IntFrom(13, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Math.c:3529:
Int a = IntFrom(9, &alloc.base);
Int b = IntFrom(5, &alloc.base);
Int m = IntFrom(13, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Math.c:3530:
Int b = IntFrom(5, &alloc.base);
Int m = IntFrom(13, &alloc.base);
Int result_value = IntInit(&alloc.base);
bool ok = IntModSub(&result_value, &a, &b, &m);- In
Math.c:3555:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(7, &alloc.base);
Int b = IntFrom(3, &alloc.base);
Int m = IntFrom(11, &alloc.base);- In
Math.c:3556:
Int a = IntFrom(7, &alloc.base);
Int b = IntFrom(3, &alloc.base);
Int m = IntFrom(11, &alloc.base);- In
Math.c:3557:
Int a = IntFrom(7, &alloc.base);
Int b = IntFrom(3, &alloc.base);
Int m = IntFrom(11, &alloc.base);
IntModSub(NULL, &a, &b, &m);- In
Math.c:3574:
DefaultAllocator alloc = DefaultAllocatorInit();
Int base = IntFrom(3, &alloc.base);
Int mod = IntFrom(17, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Math.c:3575:
Int base = IntFrom(3, &alloc.base);
Int mod = IntFrom(17, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Math.c:3576:
Int base = IntFrom(3, &alloc.base);
Int mod = IntFrom(17, &alloc.base);
Int result_value = IntInit(&alloc.base);
bool ok = IntPowMod(&result_value, &base, 13u, &mod);- In
Math.c:3596:
DefaultAllocator alloc = DefaultAllocatorInit();
Int base = IntFrom(123456789, &alloc.base);
Int mod = IntFrom(1000000007, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Math.c:3597:
Int base = IntFrom(123456789, &alloc.base);
Int mod = IntFrom(1000000007, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Math.c:3598:
Int base = IntFrom(123456789, &alloc.base);
Int mod = IntFrom(1000000007, &alloc.base);
Int result_value = IntInit(&alloc.base);
bool ok = IntPowMod(&result_value, &base, 0u, &mod);- In
Math.c:3620:
DefaultAllocator alloc = DefaultAllocatorInit();
Int base = IntFrom(2, &alloc.base);
Int mod = IntFrom(1000000007, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Math.c:3621:
Int base = IntFrom(2, &alloc.base);
Int mod = IntFrom(1000000007, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Math.c:3622:
Int base = IntFrom(2, &alloc.base);
Int mod = IntFrom(1000000007, &alloc.base);
Int result_value = IntInit(&alloc.base);
bool ok = IntPowMod(&result_value, &base, 64u, &mod);- In
Math.c:3641:
DefaultAllocator alloc = DefaultAllocatorInit();
Int base = IntFrom(2, &alloc.base);
Int mod = IntFrom(7, &alloc.base);- In
Math.c:3642:
Int base = IntFrom(2, &alloc.base);
Int mod = IntFrom(7, &alloc.base);
IntPowMod((Int *)NULL, &base, 5u, &mod);- In
Math.c:3644:
Int mod = IntFrom(7, &alloc.base);
IntPowMod((Int *)NULL, &base, 5u, &mod);
DefaultAllocatorDeinit(&alloc);- In
Math.c:3656:
DefaultAllocator alloc = DefaultAllocatorInit();
Int result_value = IntInit(&alloc.base);
Int mod = IntFrom(7, &alloc.base);- In
Math.c:3657:
Int result_value = IntInit(&alloc.base);
Int mod = IntFrom(7, &alloc.base);
IntPowMod(&result_value, (Int *)NULL, 5u, &mod);- In
Math.c:3659:
Int mod = IntFrom(7, &alloc.base);
IntPowMod(&result_value, (Int *)NULL, 5u, &mod);
DefaultAllocatorDeinit(&alloc);- In
Math.c:3671:
DefaultAllocator alloc = DefaultAllocatorInit();
Int result_value = IntInit(&alloc.base);
Int base = IntFrom(2, &alloc.base);- In
Math.c:3672:
Int result_value = IntInit(&alloc.base);
Int base = IntFrom(2, &alloc.base);
IntPowMod(&result_value, &base, 5u, (Int *)NULL);- In
Math.c:3674:
Int base = IntFrom(2, &alloc.base);
IntPowMod(&result_value, &base, 5u, (Int *)NULL);
DefaultAllocatorDeinit(&alloc);- In
Math.c:3684:
Allocator *a = ALLOCATOR_OF(&dbg);
Int x = IntFrom(123456u, a);
Int y = IntFrom(7891011u, a);
Int r = IntInit(a);- In
Math.c:3685:
Int x = IntFrom(123456u, a);
Int y = IntFrom(7891011u, a);
Int r = IntInit(a);- In
Math.c:3686:
Int x = IntFrom(123456u, a);
Int y = IntFrom(7891011u, a);
Int r = IntInit(a);
bool ok = IntMul(&r, &x, &y);- In
Math.c:3703:
Allocator *a = ALLOCATOR_OF(&dbg);
Int x = IntFrom(0u, a);
Int y = IntFrom(7891011u, a);
Int r = IntFrom(42u, a); // r starts non-empty so the internal deinit matters
- In
Math.c:3704:
Int x = IntFrom(0u, a);
Int y = IntFrom(7891011u, a);
Int r = IntFrom(42u, a); // r starts non-empty so the internal deinit matters
- In
Math.c:3705:
Int x = IntFrom(0u, a);
Int y = IntFrom(7891011u, a);
Int r = IntFrom(42u, a); // r starts non-empty so the internal deinit matters
bool ok = IntMul(&r, &x, &y);- In
Math.c:3722:
Allocator *a = ALLOCATOR_OF(&dbg);
Int x = IntFrom(0xFFFFFFFFull, a);
Int y = IntFrom(0xFFFFFFFFull, a);
Int r = IntFrom(7u, a);- In
Math.c:3723:
Int x = IntFrom(0xFFFFFFFFull, a);
Int y = IntFrom(0xFFFFFFFFull, a);
Int r = IntFrom(7u, a);- In
Math.c:3724:
Int x = IntFrom(0xFFFFFFFFull, a);
Int y = IntFrom(0xFFFFFFFFull, a);
Int r = IntFrom(7u, a);
bool ok = IntAdd(&r, &x, &y);- In
Math.c:3741:
Allocator *a = ALLOCATOR_OF(&dbg);
Int x = IntFrom(1000000u, a);
Int y = IntFrom(999983u, a);
Int r = IntFrom(7u, a);- In
Math.c:3742:
Int x = IntFrom(1000000u, a);
Int y = IntFrom(999983u, a);
Int r = IntFrom(7u, a);- In
Math.c:3743:
Int x = IntFrom(1000000u, a);
Int y = IntFrom(999983u, a);
Int r = IntFrom(7u, a);
bool ok = IntSub(&r, &x, &y);- In
Math.c:3762:
// IntAdd with a u64 operand drives int_add_u64 -> int_add_u64_in_place,
// which frees lhs/rhs temporaries on success (lines 276/277).
Int x = IntFrom(500u, a);
Int r = IntFrom(7u, a);- In
Math.c:3763:
// which frees lhs/rhs temporaries on success (lines 276/277).
Int x = IntFrom(500u, a);
Int r = IntFrom(7u, a);
bool ok = IntAdd(&r, &x, 250u);- In
Math.c:3781:
// IntMul with a u64 operand drives int_mul_u64 -> int_mul_u64_in_place,
// which frees lhs/rhs temporaries on success (lines 251/252).
Int x = IntFrom(500u, a);
Int r = IntFrom(7u, a);- In
Math.c:3782:
// which frees lhs/rhs temporaries on success (lines 251/252).
Int x = IntFrom(500u, a);
Int r = IntFrom(7u, a);
bool ok = IntMul(&r, &x, 13u);- In
Math.c:3798:
Allocator *a = ALLOCATOR_OF(&dbg);
Int x = IntFrom(1000u, a);
Int r = IntFrom(7u, a);- In
Math.c:3799:
Int x = IntFrom(1000u, a);
Int r = IntFrom(7u, a);
bool ok = IntSub(&r, &x, 250u); // int_sub_u64 frees rhs on success (1187)
- In
Math.c:3817:
// dividend >= divisor drives the long-division branch (lines 1378..1411,
// 1420..1423 replace/deinit).
Int dvd = IntFrom(1000003u, a);
Int dvs = IntFrom(101u, a);
Int q = IntFrom(7u, a);- In
Math.c:3818:
// 1420..1423 replace/deinit).
Int dvd = IntFrom(1000003u, a);
Int dvs = IntFrom(101u, a);
Int q = IntFrom(7u, a);
Int r = IntFrom(9u, a);- In
Math.c:3819:
Int dvd = IntFrom(1000003u, a);
Int dvs = IntFrom(101u, a);
Int q = IntFrom(7u, a);
Int r = IntFrom(9u, a);- In
Math.c:3820:
Int dvs = IntFrom(101u, a);
Int q = IntFrom(7u, a);
Int r = IntFrom(9u, a);
bool ok = IntDivMod(&q, &r, &dvd, &dvs);- In
Math.c:3839:
// dividend < divisor drives the else branch (line 1413: deinit+reinit q).
Int dvd = IntFrom(50u, a);
Int dvs = IntFrom(101u, a);
Int q = IntFrom(7u, a);- In
Math.c:3840:
// dividend < divisor drives the else branch (line 1413: deinit+reinit q).
Int dvd = IntFrom(50u, a);
Int dvs = IntFrom(101u, a);
Int q = IntFrom(7u, a);
Int r = IntFrom(9u, a);- In
Math.c:3841:
Int dvd = IntFrom(50u, a);
Int dvs = IntFrom(101u, a);
Int q = IntFrom(7u, a);
Int r = IntFrom(9u, a);- In
Math.c:3842:
Int dvs = IntFrom(101u, a);
Int q = IntFrom(7u, a);
Int r = IntFrom(9u, a);
bool ok = IntDivMod(&q, &r, &dvd, &dvs);- In
Math.c:3860:
Allocator *a = ALLOCATOR_OF(&dbg);
Int dvd = IntFrom(1000003u, a);
Int dvs = IntFrom(101u, a);
Int r = IntFrom(7u, a);- In
Math.c:3861:
Int dvd = IntFrom(1000003u, a);
Int dvs = IntFrom(101u, a);
Int r = IntFrom(7u, a);- In
Math.c:3862:
Int dvd = IntFrom(1000003u, a);
Int dvs = IntFrom(101u, a);
Int r = IntFrom(7u, a);
bool ok = IntDiv(&r, &dvd, &dvs); // int_div frees remainder on success (1445)
- In
Math.c:3879:
Allocator *a = ALLOCATOR_OF(&dbg);
Int dvd = IntFrom(1000u, a);
Int dvs = IntFrom(8u, a);
Int r = IntFrom(7u, a);- In
Math.c:3880:
Int dvd = IntFrom(1000u, a);
Int dvs = IntFrom(8u, a);
Int r = IntFrom(7u, a);- In
Math.c:3881:
Int dvd = IntFrom(1000u, a);
Int dvs = IntFrom(8u, a);
Int r = IntFrom(7u, a);
bool ok = IntDivExact(&r, &dvd, &dvs); // frees remainder on success (1474)
- In
Math.c:3900:
// int_div_u64 / int_div_exact_u64 / int_div_i64 etc. free divisor_value
// on success (1488, 1514, 1501, 1527).
Int dvd = IntFrom(1000u, a);
Int r1 = IntFrom(7u, a);
Int r2 = IntFrom(7u, a);- In
Math.c:3901:
// on success (1488, 1514, 1501, 1527).
Int dvd = IntFrom(1000u, a);
Int r1 = IntFrom(7u, a);
Int r2 = IntFrom(7u, a);
Int r3 = IntFrom(7u, a);- In
Math.c:3902:
Int dvd = IntFrom(1000u, a);
Int r1 = IntFrom(7u, a);
Int r2 = IntFrom(7u, a);
Int r3 = IntFrom(7u, a);- In
Math.c:3903:
Int r1 = IntFrom(7u, a);
Int r2 = IntFrom(7u, a);
Int r3 = IntFrom(7u, a);
bool ok = IntDiv(&r1, &dvd, 8u);- In
Math.c:3925:
// int_div_mod_u64 / int_div_mod_i64 free divisor_value on success
// (1540, 1553); int_mod_u64_into / int_mod_i64_into free quotient (1607/1615).
Int dvd = IntFrom(1003u, a);
Int q = IntFrom(7u, a);
Int r = IntFrom(7u, a);- In
Math.c:3926:
// (1540, 1553); int_mod_u64_into / int_mod_i64_into free quotient (1607/1615).
Int dvd = IntFrom(1003u, a);
Int q = IntFrom(7u, a);
Int r = IntFrom(7u, a);
Int m1 = IntFrom(7u, a);- In
Math.c:3927:
Int dvd = IntFrom(1003u, a);
Int q = IntFrom(7u, a);
Int r = IntFrom(7u, a);
Int m1 = IntFrom(7u, a);
Int m2 = IntFrom(7u, a);- In
Math.c:3928:
Int q = IntFrom(7u, a);
Int r = IntFrom(7u, a);
Int m1 = IntFrom(7u, a);
Int m2 = IntFrom(7u, a);- In
Math.c:3929:
Int r = IntFrom(7u, a);
Int m1 = IntFrom(7u, a);
Int m2 = IntFrom(7u, a);
bool ok = IntDivMod(&q, &r, &dvd, 100u);- In
Math.c:3951:
Allocator *a = ALLOCATOR_OF(&dbg);
Int dvd = IntFrom(1003u, a);
Int dvs = IntFrom(100u, a);
Int r = IntFrom(7u, a);- In
Math.c:3952:
Int dvd = IntFrom(1003u, a);
Int dvs = IntFrom(100u, a);
Int r = IntFrom(7u, a);- In
Math.c:3953:
Int dvd = IntFrom(1003u, a);
Int dvs = IntFrom(100u, a);
Int r = IntFrom(7u, a);
bool ok = IntMod(&r, &dvd, &dvs); // int_mod frees quotient on success (1598)
- In
Math.c:3972:
// exponent 13 = 0b1101 hits both the multiply-acc branch (1317) and the
// square-current branch (1331), and final current/acc cleanup (1336).
Int base = IntFrom(3u, a);
Int r = IntFrom(7u, a);- In
Math.c:3973:
// square-current branch (1331), and final current/acc cleanup (1336).
Int base = IntFrom(3u, a);
Int r = IntFrom(7u, a);
bool ok = IntPow(&r, &base, 13u);- In
Math.c:3990:
// Euclid loop frees x each iteration (1657), final y cleanup (1663).
Int x = IntFrom(123456u, a);
Int y = IntFrom(7890u, a);
Int r = IntFrom(7u, a);- In
Math.c:3991:
// Euclid loop frees x each iteration (1657), final y cleanup (1663).
Int x = IntFrom(123456u, a);
Int y = IntFrom(7890u, a);
Int r = IntFrom(7u, a);- In
Math.c:3992:
Int x = IntFrom(123456u, a);
Int y = IntFrom(7890u, a);
Int r = IntFrom(7u, a);
bool ok = IntGCD(&r, &x, &y);- In
Math.c:4010:
// Success path frees gcd + quotient (1689/1690).
Int x = IntFrom(21u, a);
Int y = IntFrom(6u, a);
Int r = IntFrom(7u, a);- In
Math.c:4011:
// Success path frees gcd + quotient (1689/1690).
Int x = IntFrom(21u, a);
Int y = IntFrom(6u, a);
Int r = IntFrom(7u, a);- In
Math.c:4012:
Int x = IntFrom(21u, a);
Int y = IntFrom(6u, a);
Int r = IntFrom(7u, a);
bool ok = IntLCM(&r, &x, &y);- In
Math.c:4031:
// Non-trivial cube root drives the bisection loop: low/high/mid/mid_pow
// deinits (1813,1819,1832,1837,1838), the final block (1855..1858).
Int v = IntFrom(1000000u, a);
Int root = IntFrom(7u, a);
Int rem = IntFrom(9u, a);- In
Math.c:4032:
// deinits (1813,1819,1832,1837,1838), the final block (1855..1858).
Int v = IntFrom(1000000u, a);
Int root = IntFrom(7u, a);
Int rem = IntFrom(9u, a);- In
Math.c:4033:
Int v = IntFrom(1000000u, a);
Int root = IntFrom(7u, a);
Int rem = IntFrom(9u, a);
bool ok = IntRootRem(&root, &rem, &v, 3); // 100^3 = 1e6
- In
Math.c:4051:
// Inexact root exercises the cmp>0 branch (1819/1822/1832 high update).
Int v = IntFrom(1000u, a);
Int root = IntFrom(7u, a);
Int rem = IntFrom(9u, a);- In
Math.c:4052:
// Inexact root exercises the cmp>0 branch (1819/1822/1832 high update).
Int v = IntFrom(1000u, a);
Int root = IntFrom(7u, a);
Int rem = IntFrom(9u, a);- In
Math.c:4053:
Int v = IntFrom(1000u, a);
Int root = IntFrom(7u, a);
Int rem = IntFrom(9u, a);
bool ok = IntRootRem(&root, &rem, &v, 3); // cbrt(1000)=10 exact actually
- In
Math.c:4059:
// and a genuinely inexact one
Int v2 = IntFrom(999u, a);
ok = ok && IntRootRem(&root, &rem, &v2, 3);
ok = ok && IntToU64(&root) == 9u && IntToU64(&rem) == 999u - 729u;- In
Math.c:4076:
Allocator *a = ALLOCATOR_OF(&dbg);
Int v = IntFrom(1000000u, a);
Int r = IntFrom(7u, a);- In
Math.c:4077:
Int v = IntFrom(1000000u, a);
Int r = IntFrom(7u, a);
bool ok = IntRoot(&r, &v, 3); // frees remainder on success (1877)
- In
Math.c:4094:
// Frees root + remainder on success (1904/1905).
Int sq = IntFrom(123201u, a); // 351^2
Int nsq = IntFrom(123202u, a);- In
Math.c:4095:
// Frees root + remainder on success (1904/1905).
Int sq = IntFrom(123201u, a); // 351^2
Int nsq = IntFrom(123202u, a);
bool ok = IntIsPerfectSquare(&sq) && !IntIsPerfectSquare(&nsq);- In
Math.c:4111:
// Loop frees root + remainder each degree (1934/1935).
Int pw = IntFrom(7776u, a); // 6^5
Int npw = IntFrom(7777u, a);- In
Math.c:4112:
// Loop frees root + remainder each degree (1934/1935).
Int pw = IntFrom(7776u, a); // 6^5
Int npw = IntFrom(7777u, a);
bool ok = IntIsPerfectPower(&pw) && !IntIsPerfectPower(&npw);- In
Math.c:4129:
// Drives the main loop (swap, even-stripping 1972, inner deinits) and both
// tail branches: result-1 path (1998) and nn!=1 -> 0 path requires gcd!=1.
Int x = IntFrom(1001u, a);
Int n = IntFrom(9907u, a); // prime
int jr = 0;- In
Math.c:4130:
// tail branches: result-1 path (1998) and nn!=1 -> 0 path requires gcd!=1.
Int x = IntFrom(1001u, a);
Int n = IntFrom(9907u, a); // prime
int jr = 0;- In
Math.c:4136:
// a case where gcd(a,n) != 1 -> the *out=0 branch (frees nn at 1998)
Int x2 = IntFrom(15u, a);
Int n2 = IntFrom(9u, a); // odd, gcd(15,9)=3
int jr2 = 0;- In
Math.c:4137:
// a case where gcd(a,n) != 1 -> the *out=0 branch (frees nn at 1998)
Int x2 = IntFrom(15u, a);
Int n2 = IntFrom(9u, a); // odd, gcd(15,9)=3
int jr2 = 0;
ok = ok && IntTryJacobi(&jr2, &x2, &n2) && jr2 == 0;- In
Math.c:4154:
Allocator *a = ALLOCATOR_OF(&dbg);
Int x = IntFrom(12345u, a);
Int y = IntFrom(67890u, a);
Int m = IntFrom(1009u, a);- In
Math.c:4155:
Int x = IntFrom(12345u, a);
Int y = IntFrom(67890u, a);
Int m = IntFrom(1009u, a);
Int r = IntFrom(7u, a);- In
Math.c:4156:
Int x = IntFrom(12345u, a);
Int y = IntFrom(67890u, a);
Int m = IntFrom(1009u, a);
Int r = IntFrom(7u, a);- In
Math.c:4157:
Int y = IntFrom(67890u, a);
Int m = IntFrom(1009u, a);
Int r = IntFrom(7u, a);
bool ok = IntModAdd(&r, &x, &y, &m); // frees ar/br/sum on success (2042-2044)
- In
Math.c:4176:
// ar >= br branch (2098/2099 frees ar/br).
Int x = IntFrom(900u, a);
Int y = IntFrom(100u, a);
Int m = IntFrom(1009u, a);- In
Math.c:4177:
// ar >= br branch (2098/2099 frees ar/br).
Int x = IntFrom(900u, a);
Int y = IntFrom(100u, a);
Int m = IntFrom(1009u, a);
Int r = IntFrom(7u, a);- In
Math.c:4178:
Int x = IntFrom(900u, a);
Int y = IntFrom(100u, a);
Int m = IntFrom(1009u, a);
Int r = IntFrom(7u, a);- In
Math.c:4179:
Int y = IntFrom(100u, a);
Int m = IntFrom(1009u, a);
Int r = IntFrom(7u, a);
bool ok = IntModSub(&r, &x, &y, &m);- In
Math.c:4198:
// ar < br branch: nonzero diff -> modulus-diff (2095 frees diff).
Int x = IntFrom(100u, a);
Int y = IntFrom(900u, a);
Int m = IntFrom(1009u, a);- In
Math.c:4199:
// ar < br branch: nonzero diff -> modulus-diff (2095 frees diff).
Int x = IntFrom(100u, a);
Int y = IntFrom(900u, a);
Int m = IntFrom(1009u, a);
Int r = IntFrom(7u, a);- In
Math.c:4200:
Int x = IntFrom(100u, a);
Int y = IntFrom(900u, a);
Int m = IntFrom(1009u, a);
Int r = IntFrom(7u, a);- In
Math.c:4201:
Int y = IntFrom(900u, a);
Int m = IntFrom(1009u, a);
Int r = IntFrom(7u, a);
bool ok = IntModSub(&r, &x, &y, &m);- In
Math.c:4225:
// Instead exercise the ar<br with diff==0 by x=0 mod m, y=0 mod m won't.
// Use the generic ar<br path already covered; here cover equal-after-mod.
Int x = IntFrom(5u, a);
Int y = IntFrom(5u, a);
Int m = IntFrom(1009u, a);- In
Math.c:4226:
// Use the generic ar<br path already covered; here cover equal-after-mod.
Int x = IntFrom(5u, a);
Int y = IntFrom(5u, a);
Int m = IntFrom(1009u, a);
Int r = IntFrom(7u, a);- In
Math.c:4227:
Int x = IntFrom(5u, a);
Int y = IntFrom(5u, a);
Int m = IntFrom(1009u, a);
Int r = IntFrom(7u, a);- In
Math.c:4228:
Int y = IntFrom(5u, a);
Int m = IntFrom(1009u, a);
Int r = IntFrom(7u, a);
bool ok = IntModSub(&r, &x, &y, &m);- In
Math.c:4246:
Allocator *a = ALLOCATOR_OF(&dbg);
Int x = IntFrom(12345u, a);
Int y = IntFrom(67890u, a);
Int m = IntFrom(1009u, a);- In
Math.c:4247:
Int x = IntFrom(12345u, a);
Int y = IntFrom(67890u, a);
Int m = IntFrom(1009u, a);
Int r = IntFrom(7u, a);- In
Math.c:4248:
Int x = IntFrom(12345u, a);
Int y = IntFrom(67890u, a);
Int m = IntFrom(1009u, a);
Int r = IntFrom(7u, a);- In
Math.c:4249:
Int y = IntFrom(67890u, a);
Int m = IntFrom(1009u, a);
Int r = IntFrom(7u, a);
bool ok = IntModMul(&r, &x, &y, &m); // frees ar/br/prod (2126-2128)
- In
Math.c:4267:
Allocator *a = ALLOCATOR_OF(&dbg);
Int x = IntFrom(12345u, a);
Int m = IntFrom(1009u, a);
Int r = IntFrom(7u, a);- In
Math.c:4268:
Int x = IntFrom(12345u, a);
Int m = IntFrom(1009u, a);
Int r = IntFrom(7u, a);- In
Math.c:4269:
Int x = IntFrom(12345u, a);
Int m = IntFrom(1009u, a);
Int r = IntFrom(7u, a);
bool ok = IntSquareMod(&r, &x, &m);- In
Math.c:4287:
// IntModDiv frees inverse on success (2160).
Int x = IntFrom(42u, a);
Int y = IntFrom(5u, a);
Int m = IntFrom(1009u, a);- In
Math.c:4288:
// IntModDiv frees inverse on success (2160).
Int x = IntFrom(42u, a);
Int y = IntFrom(5u, a);
Int m = IntFrom(1009u, a);
Int r = IntFrom(7u, a);- In
Math.c:4289:
Int x = IntFrom(42u, a);
Int y = IntFrom(5u, a);
Int m = IntFrom(1009u, a);
Int r = IntFrom(7u, a);- In
Math.c:4290:
Int y = IntFrom(5u, a);
Int m = IntFrom(1009u, a);
Int r = IntFrom(7u, a);
bool ok = IntModDiv(&r, &x, &y, &m);- In
Math.c:4309:
// int_pow_u64_mod: multiply-acc (2201) and square (2215), final cleanup
// (2220 frees base_mod).
Int base = IntFrom(7u, a);
Int m = IntFrom(1000000007u, a);
Int r = IntFrom(9u, a);- In
Math.c:4310:
// (2220 frees base_mod).
Int base = IntFrom(7u, a);
Int m = IntFrom(1000000007u, a);
Int r = IntFrom(9u, a);- In
Math.c:4311:
Int base = IntFrom(7u, a);
Int m = IntFrom(1000000007u, a);
Int r = IntFrom(9u, a);
bool ok = IntPowMod(&r, &base, 13u, &m);- In
Math.c:4329:
// int_pow_mod (Int exponent) main loop + final base_mod/exp cleanup.
Int base = IntFrom(7u, a);
Int exp = IntFrom(13u, a);
Int m = IntFrom(1000000007u, a);- In
Math.c:4330:
// int_pow_mod (Int exponent) main loop + final base_mod/exp cleanup.
Int base = IntFrom(7u, a);
Int exp = IntFrom(13u, a);
Int m = IntFrom(1000000007u, a);
Int r = IntFrom(9u, a);- In
Math.c:4331:
Int base = IntFrom(7u, a);
Int exp = IntFrom(13u, a);
Int m = IntFrom(1000000007u, a);
Int r = IntFrom(9u, a);- In
Math.c:4332:
Int exp = IntFrom(13u, a);
Int m = IntFrom(1000000007u, a);
Int r = IntFrom(9u, a);
bool ok = IntPowMod(&r, &base, &exp, &m);- In
Math.c:4350:
Allocator *a = ALLOCATOR_OF(&dbg);
Int v = IntFrom(17u, a);
Int m = IntFrom(3120u, a); // gcd(17,3120)=1
Int r = IntFrom(7u, a);- In
Math.c:4351:
Int v = IntFrom(17u, a);
Int m = IntFrom(3120u, a); // gcd(17,3120)=1
Int r = IntFrom(7u, a);- In
Math.c:4352:
Int v = IntFrom(17u, a);
Int m = IntFrom(3120u, a); // gcd(17,3120)=1
Int r = IntFrom(7u, a);
bool ok = IntModInv(&r, &v, &m);- In
Math.c:4372:
// t.negative && !zero branch (modulus - mag_mod, frees positive/mag_mod
// and mag_mod at 2414).
Int v = IntFrom(3u, a);
Int m = IntFrom(7u, a); // inverse of 3 mod 7 is 5
Int r = IntFrom(9u, a);- In
Math.c:4373:
// and mag_mod at 2414).
Int v = IntFrom(3u, a);
Int m = IntFrom(7u, a); // inverse of 3 mod 7 is 5
Int r = IntFrom(9u, a);- In
Math.c:4374:
Int v = IntFrom(3u, a);
Int m = IntFrom(7u, a); // inverse of 3 mod 7 is 5
Int r = IntFrom(9u, a);
bool ok = IntModInv(&r, &v, &m);- In
Math.c:4394:
// false; the function still frees reduced/r/new_r/one/t/new_t at the tail
// (2419-2424). All those carry allocations.
Int v = IntFrom(6u, a);
Int m = IntFrom(9u, a); // gcd(6,9)=3, no inverse
Int r = IntFrom(7u, a);- In
Math.c:4395:
// (2419-2424). All those carry allocations.
Int v = IntFrom(6u, a);
Int m = IntFrom(9u, a); // gcd(6,9)=3, no inverse
Int r = IntFrom(7u, a);- In
Math.c:4396:
Int v = IntFrom(6u, a);
Int m = IntFrom(9u, a); // gcd(6,9)=3, no inverse
Int r = IntFrom(7u, a);
bool ok = !IntModInv(&r, &v, &m); // returns false
- In
Math.c:4413:
// modulus 7 (7 % 4 == 3) drives the fast path: frees exponent + a (2488/2489).
Int v = IntFrom(2u, a); // 2 is QR mod 7 (3^2=2)
Int m = IntFrom(7u, a);
Int r = IntFrom(9u, a);- In
Math.c:4414:
// modulus 7 (7 % 4 == 3) drives the fast path: frees exponent + a (2488/2489).
Int v = IntFrom(2u, a); // 2 is QR mod 7 (3^2=2)
Int m = IntFrom(7u, a);
Int r = IntFrom(9u, a);- In
Math.c:4415:
Int v = IntFrom(2u, a); // 2 is QR mod 7 (3^2=2)
Int m = IntFrom(7u, a);
Int r = IntFrom(9u, a);
bool ok = IntModSqrt(&r, &v, &m);- In
Math.c:4436:
// the witness-search loop, the t-loop with t_power/b/b_sq, and the success
// int_replace path (2724-2735). 2 is a QR mod 17 (6^2=36=2).
Int v = IntFrom(2u, a);
Int m = IntFrom(17u, a);
Int r = IntFrom(9u, a);- In
Math.c:4437:
// int_replace path (2724-2735). 2 is a QR mod 17 (6^2=36=2).
Int v = IntFrom(2u, a);
Int m = IntFrom(17u, a);
Int r = IntFrom(9u, a);- In
Math.c:4438:
Int v = IntFrom(2u, a);
Int m = IntFrom(17u, a);
Int r = IntFrom(9u, a);
bool ok = IntModSqrt(&r, &v, &m);- In
Math.c:4458:
// modulus 41 (41 % 4 == 1, 41-1 = 40 = 8*5 so m=3 levels) drives the inner
// b-squaring loop (2662) and the c/t/b reassignments more deeply.
Int v = IntFrom(10u, a); // 10 is QR mod 41 (16^2=256=256-246=10)
Int m = IntFrom(41u, a);
Int r = IntFrom(9u, a);- In
Math.c:4459:
// b-squaring loop (2662) and the c/t/b reassignments more deeply.
Int v = IntFrom(10u, a); // 10 is QR mod 41 (16^2=256=256-246=10)
Int m = IntFrom(41u, a);
Int r = IntFrom(9u, a);- In
Math.c:4460:
Int v = IntFrom(10u, a); // 10 is QR mod 41 (16^2=256=256-246=10)
Int m = IntFrom(41u, a);
Int r = IntFrom(9u, a);
bool ok = IntModSqrt(&r, &v, &m);- In
Math.c:4479:
// value % modulus == 0 -> zero branch frees a (2449).
Int v = IntFrom(0u, a);
Int m = IntFrom(17u, a);
Int r = IntFrom(9u, a);- In
Math.c:4480:
// value % modulus == 0 -> zero branch frees a (2449).
Int v = IntFrom(0u, a);
Int m = IntFrom(17u, a);
Int r = IntFrom(9u, a);- In
Math.c:4481:
Int v = IntFrom(0u, a);
Int m = IntFrom(17u, a);
Int r = IntFrom(9u, a);
bool ok = IntModSqrt(&r, &v, &m) && IntIsZero(&r);- In
Math.c:4499:
// modulus 2 path: int_replace(result, &a) (no extra deinit, but reaches
// the compare-u64==2 branch); a is moved into result.
Int v = IntFrom(1u, a);
Int m = IntFrom(2u, a);
Int r = IntFrom(9u, a);- In
Math.c:4500:
// the compare-u64==2 branch); a is moved into result.
Int v = IntFrom(1u, a);
Int m = IntFrom(2u, a);
Int r = IntFrom(9u, a);- In
Math.c:4501:
Int v = IntFrom(1u, a);
Int m = IntFrom(2u, a);
Int r = IntFrom(9u, a);
bool ok = IntModSqrt(&r, &v, &m) && IntToU64(&r) == 1u;- In
Math.c:4519:
// jacobi != 1 -> non-residue, frees a and returns false (2473's deinit at
// the early non-residue return). 3 is a non-residue mod 7.
Int v = IntFrom(3u, a);
Int m = IntFrom(7u, a);
Int r = IntFrom(9u, a);- In
Math.c:4520:
// the early non-residue return). 3 is a non-residue mod 7.
Int v = IntFrom(3u, a);
Int m = IntFrom(7u, a);
Int r = IntFrom(9u, a);- In
Math.c:4521:
Int v = IntFrom(3u, a);
Int m = IntFrom(7u, a);
Int r = IntFrom(9u, a);
bool ok = !IntModSqrt(&r, &v, &m);- In
Math.c:4538:
// composite (non-prime) odd modulus -> !prime branch frees a (2465).
Int v = IntFrom(2u, a);
Int m = IntFrom(9u, a); // odd composite
Int r = IntFrom(9u, a);- In
Math.c:4539:
// composite (non-prime) odd modulus -> !prime branch frees a (2465).
Int v = IntFrom(2u, a);
Int m = IntFrom(9u, a); // odd composite
Int r = IntFrom(9u, a);- In
Math.c:4540:
Int v = IntFrom(2u, a);
Int m = IntFrom(9u, a); // odd composite
Int r = IntFrom(9u, a);
bool ok = !IntModSqrt(&r, &v, &m);- In
Math.c:4557:
// even modulus (>2) -> IntIsEven branch frees a (2465).
Int v = IntFrom(3u, a);
Int m = IntFrom(8u, a);
Int r = IntFrom(9u, a);- In
Math.c:4558:
// even modulus (>2) -> IntIsEven branch frees a (2465).
Int v = IntFrom(3u, a);
Int m = IntFrom(8u, a);
Int r = IntFrom(9u, a);- In
Math.c:4559:
Int v = IntFrom(3u, a);
Int m = IntFrom(8u, a);
Int r = IntFrom(9u, a);
bool ok = !IntModSqrt(&r, &v, &m);- In
Math.c:4579:
// witness inner loop (2839), per-iteration base/x (2853/2854), and the d /
// n_minus_one tail (2860/2861).
Int prime = IntFrom(1000003u, a); // prime
Int composite = IntFrom(1000005u, a); // composite
- In
Math.c:4580:
// n_minus_one tail (2860/2861).
Int prime = IntFrom(1000003u, a); // prime
Int composite = IntFrom(1000005u, a); // composite
bool ok = IntIsProbablePrime(&prime) && !IntIsProbablePrime(&composite);- In
Math.c:4598:
// (squaring x repeatedly) before failing. 2047 = 23*89 passes base 2 (it's
// a 2-SPRP) but fails on another base -> exercises x squaring (2839).
Int n = IntFrom(2047u, a);
bool ok = !IntIsProbablePrime(&n);- In
Math.c:4614:
// Drives candidate-stepping loop (frees candidate on success at 2924, and
// the +2 stepping at 2918). Starting from an even-ish composite.
Int v = IntFrom(1000000u, a);
Int r = IntFrom(7u, a);- In
Math.c:4615:
// the +2 stepping at 2918). Starting from an even-ish composite.
Int v = IntFrom(1000000u, a);
Int r = IntFrom(7u, a);
bool ok = IntNextPrime(&r, &v);- In
Math.c:4633:
// value <= 1 -> two path (2879 int_replace) and the candidate<=2 path
// (2902/2903 frees candidate then replaces with two).
Int v0 = IntFrom(0u, a);
Int r0 = IntFrom(7u, a);
Int v1 = IntFrom(2u, a);- In
Math.c:4634:
// (2902/2903 frees candidate then replaces with two).
Int v0 = IntFrom(0u, a);
Int r0 = IntFrom(7u, a);
Int v1 = IntFrom(2u, a);
Int r1 = IntFrom(7u, a);- In
Math.c:4635:
Int v0 = IntFrom(0u, a);
Int r0 = IntFrom(7u, a);
Int v1 = IntFrom(2u, a);
Int r1 = IntFrom(7u, a);- In
Math.c:4636:
Int r0 = IntFrom(7u, a);
Int v1 = IntFrom(2u, a);
Int r1 = IntFrom(7u, a);
bool ok = IntNextPrime(&r0, &v0) && IntToU64(&r0) == 2u;- In
Math.c:4654:
Allocator *a = ALLOCATOR_OF(&dbg);
Int x = IntFrom(123456u, a);
Int y = IntFrom(7891011u, a);
Int r = IntFrom(0xDEADBEEFu, a); // pre-populated: holds a live buffer
- In
Math.c:4655:
Int x = IntFrom(123456u, a);
Int y = IntFrom(7891011u, a);
Int r = IntFrom(0xDEADBEEFu, a); // pre-populated: holds a live buffer
- In
Math.c:4656:
Int x = IntFrom(123456u, a);
Int y = IntFrom(7891011u, a);
Int r = IntFrom(0xDEADBEEFu, a); // pre-populated: holds a live buffer
bool ok = IntMul(&r, &x, &y);- In
Math.c:4673:
Allocator *a = ALLOCATOR_OF(&dbg);
Int dvd = IntFrom(1000u, a);
Int r = IntFrom(7u, a);- In
Math.c:4674:
Int dvd = IntFrom(1000u, a);
Int r = IntFrom(7u, a);
bool ok = IntDivExact(&r, &dvd, (i64)8);- In
Math.c:4703:
for (u64 si = 0; si < samples && ok; si++) {
u64 vv = 1u + (si * (p - 2u)) / (samples - 1u);
Int v = IntFrom(vv, a);
Int m = IntFrom(p, a);
Int r = IntFrom(9u, a);- In
Math.c:4704:
u64 vv = 1u + (si * (p - 2u)) / (samples - 1u);
Int v = IntFrom(vv, a);
Int m = IntFrom(p, a);
Int r = IntFrom(9u, a);- In
Math.c:4705:
Int v = IntFrom(vv, a);
Int m = IntFrom(p, a);
Int r = IntFrom(9u, a);
bool found = IntModSqrt(&r, &v, &m);- In
Math.c:4728:
Allocator *alloc = ALLOCATOR_OF(&dbg);
Int value = IntFrom(7u, alloc);
Int modulus = IntFrom(40u, alloc); // 7 * 23 = 161 = 1 (mod 40)
Int inverse = IntFrom(0u, alloc);- In
Math.c:4729:
Int value = IntFrom(7u, alloc);
Int modulus = IntFrom(40u, alloc); // 7 * 23 = 161 = 1 (mod 40)
Int inverse = IntFrom(0u, alloc);- In
Math.c:4730:
Int value = IntFrom(7u, alloc);
Int modulus = IntFrom(40u, alloc); // 7 * 23 = 161 = 1 (mod 40)
Int inverse = IntFrom(0u, alloc);
bool ok = IntModInv(&inverse, &value, &modulus);- In
Math.c:4748:
Allocator *alloc = ALLOCATOR_OF(&dbg);
Int value = IntFrom(9u, alloc);
Int modulus = IntFrom(41u, alloc); // 41-1 = 8*5 -> several Tonelli rounds
Int root = IntFrom(0u, alloc);- In
Math.c:4749:
Int value = IntFrom(9u, alloc);
Int modulus = IntFrom(41u, alloc); // 41-1 = 8*5 -> several Tonelli rounds
Int root = IntFrom(0u, alloc);
Int check = IntFrom(0u, alloc);- In
Math.c:4750:
Int value = IntFrom(9u, alloc);
Int modulus = IntFrom(41u, alloc); // 41-1 = 8*5 -> several Tonelli rounds
Int root = IntFrom(0u, alloc);
Int check = IntFrom(0u, alloc);- In
Math.c:4751:
Int modulus = IntFrom(41u, alloc); // 41-1 = 8*5 -> several Tonelli rounds
Int root = IntFrom(0u, alloc);
Int check = IntFrom(0u, alloc);
bool ok = IntModSqrt(&root, &value, &modulus);- In
Math.c:4771:
Allocator *alloc = ALLOCATOR_OF(&dbg);
Int value = IntFrom(2u, alloc);
Int modulus = IntFrom(7u, alloc); // 7 % 4 == 3
Int root = IntFrom(0u, alloc);- In
Math.c:4772:
Int value = IntFrom(2u, alloc);
Int modulus = IntFrom(7u, alloc); // 7 % 4 == 3
Int root = IntFrom(0u, alloc);
Int check = IntFrom(0u, alloc);- In
Math.c:4773:
Int value = IntFrom(2u, alloc);
Int modulus = IntFrom(7u, alloc); // 7 % 4 == 3
Int root = IntFrom(0u, alloc);
Int check = IntFrom(0u, alloc);- In
Math.c:4774:
Int modulus = IntFrom(7u, alloc); // 7 % 4 == 3
Int root = IntFrom(0u, alloc);
Int check = IntFrom(0u, alloc);
bool ok = IntModSqrt(&root, &value, &modulus);- In
Math.c:4794:
Allocator *alloc = ALLOCATOR_OF(&dbg);
Int m = IntFrom(7u, alloc);
Int r = IntFrom(0u, alloc);- In
Math.c:4795:
Int m = IntFrom(7u, alloc);
Int r = IntFrom(0u, alloc);
// ar >= br branch: 5 - 2 = 3 (mod 7)
- In
Math.c:4798:
// ar >= br branch: 5 - 2 = 3 (mod 7)
Int a1 = IntFrom(5u, alloc), b1 = IntFrom(2u, alloc);
bool ok = IntModSub(&r, &a1, &b1, &m) && IntCompare(&r, 3u) == 0;
// ar < br branch: 2 - 5 = -3 = 4 (mod 7)
- In
Math.c:4801:
bool ok = IntModSub(&r, &a1, &b1, &m) && IntCompare(&r, 3u) == 0;
// ar < br branch: 2 - 5 = -3 = 4 (mod 7)
Int a2 = IntFrom(2u, alloc), b2 = IntFrom(5u, alloc);
ok = ok && IntModSub(&r, &a2, &b2, &m) && IntCompare(&r, 4u) == 0;
// equal branch: 5 - 12 = 0 (mod 7)
- In
Math.c:4804:
ok = ok && IntModSub(&r, &a2, &b2, &m) && IntCompare(&r, 4u) == 0;
// equal branch: 5 - 12 = 0 (mod 7)
Int a3 = IntFrom(5u, alloc), b3 = IntFrom(12u, alloc);
ok = ok && IntModSub(&r, &a3, &b3, &m) && IntIsZero(&r);- In
Math.c:4825:
Allocator *alloc = ALLOCATOR_OF(&dbg);
Int value = IntFrom(100u, alloc);
Int next = IntFrom(0u, alloc);- In
Math.c:4826:
Int value = IntFrom(100u, alloc);
Int next = IntFrom(0u, alloc);
bool ok = IntNextPrime(&next, &value);- In
Math.c:4843:
Allocator *alloc = ALLOCATOR_OF(&dbg);
Int value = IntFrom(561u, alloc);
bool error = false;
bool prime = IntIsProbablePrime(&value, &error);- In
Math.c:4856:
int main(void) {
WriteFmt("[INFO] Starting Int.Math tests\n\n");
TestFunction tests[] = {- In
Math.c:5083:
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
Convert.c:4:
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Allocator/Debug.h>
#include <Misra/Std/Container/Int.h>
#include <Misra/Std/Log.h>
#include <Misra/Std/Memory.h>- In
Convert.c:98:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(13, ALLOCATOR_OF(&alloc));
Str text = IntToBinary(&value);- In
Convert.c:112:
bool test_int_bytes_le_round_trip(void) {
WriteFmt("Testing Int little-endian byte conversion\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Convert.c:118:
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
Convert.c:133:
bool test_int_bytes_be_round_trip(void) {
WriteFmt("Testing Int big-endian byte conversion\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Convert.c:139:
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);- In
Convert.c:154:
bool test_int_binary_round_trip(void) {
WriteFmt("Testing Int binary round trip\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Convert.c:158:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFromBinary("001011", ALLOCATOR_OF(&alloc));
Str text = IntToBinary(&value);- In
Convert.c:171:
bool test_int_decimal_round_trip(void) {
WriteFmt("Testing Int decimal round trip\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Convert.c:176:
Zstr digits = "123456789012345678901234567890";
Int value = IntFromStr(digits, ALLOCATOR_OF(&alloc));
Str text = IntToStr(&value);- In
Convert.c:188:
bool test_int_radix_round_trip(void) {
WriteFmt("Testing Int radix conversion round trip\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Convert.c:192:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFromStrRadix("zz", 36, ALLOCATOR_OF(&alloc));
Str text = IntToStrRadix(&value, 36, false);- In
Convert.c:205:
bool test_int_upper_hex_radix(void) {
WriteFmt("Testing Int uppercase radix conversion\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Convert.c:209:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(0xBEEF, ALLOCATOR_OF(&alloc));
Str text = IntToStrRadix(&value, 16, true);- In
Convert.c:233:
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));- In
Convert.c:252:
DefaultAllocator alloc = DefaultAllocatorInit();
Int lhs = IntFromBinary("0001011", ALLOCATOR_OF(&alloc));
Int rhs = IntFrom(11, ALLOCATOR_OF(&alloc));- In
Convert.c:253:
Int lhs = IntFromBinary("0001011", ALLOCATOR_OF(&alloc));
Int rhs = IntFrom(11, ALLOCATOR_OF(&alloc));
bool result = IntCompare(&lhs, &rhs) == 0;- In
Convert.c:265:
bool test_int_zero_binary(void) {
WriteFmt("Testing Int zero binary conversion\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Convert.c:269:
DefaultAllocator alloc = DefaultAllocatorInit();
Int zero = IntFromBinary("0", ALLOCATOR_OF(&alloc));
Str text = IntToBinary(&zero);
bool error = true;- In
Convert.c:286:
bool test_int_binary_prefix_and_separators(void) {
WriteFmt("Testing Int binary prefix and separators\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Convert.c:290:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFromBinary("0b1010_0011", ALLOCATOR_OF(&alloc));
bool result = IntToU64(&value) == 163;- In
Convert.c:301:
bool test_int_octal_round_trip(void) {
WriteFmt("Testing Int octal round trip\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Convert.c:305:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFromOctStr("0o7_55", ALLOCATOR_OF(&alloc));
Str text = IntToOctStr(&value);- In
Convert.c:318:
bool test_int_hex_round_trip(void) {
WriteFmt("Testing Int hex round trip\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Convert.c:323:
Zstr hex = "deadbeefcafebabe1234";
Int value = IntFromHexStr(hex, ALLOCATOR_OF(&alloc));
Str text = IntToHexStr(&value);- In
Convert.c:339:
DefaultAllocator alloc = DefaultAllocatorInit();
Int parsed = IntFromBinary("10a1", ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromBinary(&value, "10a1");- In
Convert.c:340:
Int parsed = IntFromBinary("10a1", ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromBinary(&value, "10a1");- In
Convert.c:357:
DefaultAllocator alloc = DefaultAllocatorInit();
Int parsed = IntFromStr("12x3", ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromStr(&value, "12x3");- In
Convert.c:358:
Int parsed = IntFromStr("12x3", ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromStr(&value, "12x3");- In
Convert.c:375:
DefaultAllocator alloc = DefaultAllocatorInit();
Int parsed = IntFromHexStr("12g3", ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromHexStr(&value, "12g3");- In
Convert.c:376:
Int parsed = IntFromHexStr("12g3", ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromHexStr(&value, "12g3");- In
Convert.c:393:
DefaultAllocator alloc = DefaultAllocatorInit();
Int parsed = IntFromStrRadix("102", 2, ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromStrRadix(&value, "102", 2);- In
Convert.c:394:
Int parsed = IntFromStrRadix("102", 2, ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromStrRadix(&value, "102", 2);- In
Convert.c:411:
DefaultAllocator alloc = DefaultAllocatorInit();
Int parsed = IntFromStrRadix("10", 1, ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromStrRadix(&value, "10", 1);- In
Convert.c:412:
Int parsed = IntFromStrRadix("10", 1, ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromStrRadix(&value, "10", 1);- In
Convert.c:429:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(1, ALLOCATOR_OF(&alloc));
u64 out = 0;
bool error = false;- In
Convert.c:450:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(255, ALLOCATOR_OF(&alloc));
Str text = IntToStrRadix(&value, 37, false);- In
Convert.c:476:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntInit(ALLOCATOR_OF(&alloc));
IntTryFromBinary(&value, (Zstr)NULL);
IntDeinit(&value);- In
Convert.c:498:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntInit(ALLOCATOR_OF(&alloc));
IntTryFromStr(&value, (Zstr)NULL);
IntDeinit(&value);- In
Convert.c:520:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntInit(ALLOCATOR_OF(&alloc));
IntTryFromStrRadix(&value, (Zstr)NULL, 10);
IntDeinit(&value);- In
Convert.c:542:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntInit(ALLOCATOR_OF(&alloc));
IntTryFromOctStr(&value, (Zstr)NULL);
IntDeinit(&value);- In
Convert.c:564:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntInit(ALLOCATOR_OF(&alloc));
IntTryFromHexStr(&value, (Zstr)NULL);
IntDeinit(&value);- In
Convert.c:586:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(1, ALLOCATOR_OF(&alloc));
IntToBytesLE(&value, NULL, 1);
DefaultAllocatorDeinit(&alloc);- In
Convert.c:597:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(1, ALLOCATOR_OF(&alloc));
u8 byte = 0;- In
Convert.c:616:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom((u64)13u, &alloc.base);
Int b = IntFrom((u64)21u, &alloc.base);
Int product = IntInit(&alloc.base);- In
Convert.c:617:
Int a = IntFrom((u64)13u, &alloc.base);
Int b = IntFrom((u64)21u, &alloc.base);
Int product = IntInit(&alloc.base);- In
Convert.c:618:
Int a = IntFrom((u64)13u, &alloc.base);
Int b = IntFrom((u64)21u, &alloc.base);
Int product = IntInit(&alloc.base);
bool ok = IntMul(&product, &a, &b);- In
Convert.c:646:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromStrRadix(&value, "_", 10);- In
Convert.c:668:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool ok = IntTryFromStrRadix(&value, "7", 10);
bool result = ok && (IntToU64(&value) == 7);- In
Convert.c:690:
DefaultAllocator alloc = DefaultAllocatorInit();
Int valid = IntInit(ALLOCATOR_OF(&alloc));
Int invalid = IntInit(ALLOCATOR_OF(&alloc));- In
Convert.c:691:
Int valid = IntInit(ALLOCATOR_OF(&alloc));
Int invalid = IntInit(ALLOCATOR_OF(&alloc));
bool ok_valid = IntTryFromStrRadix(&valid, "5", 10);- In
Convert.c:732:
Str text = StrInitFromZstr("0b101", &alloc);
Int out = IntInit(&alloc.base);
bool ok = int_try_from_binary_str(&out, &text);
bool result = ok && (IntToU64(&out) == 5u);- In
Convert.c:759:
Str text = StrInitFromZstr("0B101", &alloc);
Int out = IntInit(&alloc.base);
bool ok = int_try_from_binary_str(&out, &text);
bool result = ok && (IntToU64(&out) == 5u);- In
Convert.c:786:
Str text = StrInitFromZstr("1101", &alloc);
Int out = IntInit(&alloc.base);
bool ok = int_try_from_binary_str(&out, &text);
bool result = ok && (IntToU64(&out) == 13u);- In
Convert.c:820:
Str text = StrInitFromZstr("0o17", &alloc);
Int out = IntInit(&alloc.base);
bool ok = int_try_from_oct_str_str(&out, &text);
bool result = ok && (IntToU64(&out) == 15u);- In
Convert.c:846:
Str text = StrInitFromZstr("0O17", &alloc);
Int out = IntInit(&alloc.base);
bool ok = int_try_from_oct_str_str(&out, &text);
bool result = ok && (IntToU64(&out) == 15u);- In
Convert.c:871:
Str text = StrInitFromZstr("17", &alloc);
Int out = IntInit(&alloc.base);
bool ok = int_try_from_oct_str_str(&out, &text);
bool result = ok && (IntToU64(&out) == 15u);- In
Convert.c:890:
DefaultAllocator alloc = DefaultAllocatorInit();
Int small = IntFrom(7u, &alloc.base);
Int mid = IntFrom(255u, &alloc.base);
Int big = IntFromStr("123456789012345678901234567890", &alloc.base);- In
Convert.c:891:
Int small = IntFrom(7u, &alloc.base);
Int mid = IntFrom(255u, &alloc.base);
Int big = IntFromStr("123456789012345678901234567890", &alloc.base);- In
Convert.c:892:
Int small = IntFrom(7u, &alloc.base);
Int mid = IntFrom(255u, &alloc.base);
Int big = IntFromStr("123456789012345678901234567890", &alloc.base);
Str dec_small = IntToStrRadix(&small, 10, false, &alloc.base);- In
Convert.c:924:
DefaultAllocator alloc = DefaultAllocatorInit();
Int parsed_dec = IntFromStrRadix("987654321987654321", 10, &alloc.base);
Int parsed_hex = IntFromStrRadix("deadbeef", 16, &alloc.base);- In
Convert.c:925:
Int parsed_dec = IntFromStrRadix("987654321987654321", 10, &alloc.base);
Int parsed_hex = IntFromStrRadix("deadbeef", 16, &alloc.base);
Str back_dec = IntToStrRadix(&parsed_dec, 10, false, &alloc.base);- In
Convert.c:958:
DefaultAllocator alloc = DefaultAllocatorInit();
Int out = IntInit(&alloc.base);
bool parsed = IntTryFromStrRadix(&out, "AZ", 36);- In
Convert.c:981:
DefaultAllocator alloc = DefaultAllocatorInit();
Int out = IntInit(&alloc.base);
bool parsed = IntTryFromStrRadix(&out, "FF", 16);- In
Convert.c:1005:
Str text = StrInitFromZstr("123", &alloc);
Int out = IntInit(&alloc.base);
bool parsed = IntTryFromStr(&out, &text);- In
Convert.c:1036:
Str text = StrInitFromZstr("+5", &alloc);
Int out = IntInit(&alloc.base);
bool parsed = IntTryFromStr(&out, &text);- In
Convert.c:1060:
Str digits = StrInitFromZstr("123", ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool ok = IntTryFromStrRadix(&value, &digits, 10);- In
Convert.c:1088:
Str digits = StrInitFromZstr("+5", ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool ok = IntTryFromStrRadix(&value, &digits, 10);- In
Convert.c:1112:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(0x1234, ALLOCATOR_OF(&alloc));
u8 out[8] = {0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA};
u64 written = IntToBytesLE(&value, out, sizeof(out));- In
Convert.c:1137:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(1, ALLOCATOR_OF(&alloc));
u8 out[4] = {0xAA, 0xAA, 0xAA, 0xAA};
u64 written = IntToBytesLE(&value, out, sizeof(out));- In
Convert.c:1159:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(0x1234, ALLOCATOR_OF(&alloc));
u8 out[8] = {0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA};
u64 written = IntToBytesBE(&value, out, sizeof(out));- In
Convert.c:1184:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(1, ALLOCATOR_OF(&alloc));
u8 out[4] = {0xAA, 0xAA, 0xAA, 0xAA};
u64 written = IntToBytesBE(&value, out, sizeof(out));- In
Convert.c:1210:
DefaultAllocator alloc = DefaultAllocatorInit();
Int out = IntInit(&alloc.base);
const char *text = "+5";- In
Convert.c:1230:
DefaultAllocator alloc = DefaultAllocatorInit();
Int out = IntInit(&alloc.base);
const char *text = "42";- In
Convert.c:1250:
DefaultAllocator alloc = DefaultAllocatorInit();
Int out = IntInit(&alloc.base);
bool ok = IntTryFromStrRadix(&out, "+5", (u8)10);- In
Convert.c:1268:
DefaultAllocator alloc = DefaultAllocatorInit();
Int out = IntInit(&alloc.base);
bool ok = IntTryFromOctStr(&out, "17");- In
Convert.c:1287:
DefaultAllocator alloc = DefaultAllocatorInit();
Int out = IntInit(&alloc.base);
bool ok = IntTryFromOctStr(&out, "017");- In
Convert.c:1306:
DefaultAllocator alloc = DefaultAllocatorInit();
Int a = IntFrom(1, &alloc.base);
Int b = IntFrom(257, &alloc.base);- In
Convert.c:1307:
Int a = IntFrom(1, &alloc.base);
Int b = IntFrom(257, &alloc.base);
u64 ha = int_hash(&a, 0);- In
Convert.c:1333:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFromBytesBE((const u8 *)0, 0, &alloc.base);
bool fail = (IntCompare(&value, 0u) != 0);- In
Convert.c:1351:
u8 bytes[3] = {0x01, 0x02, 0x03};
Int value = IntFromBytesBE(bytes, sizeof(bytes), &alloc.base);
bool fail = (IntCompare(&value, 0x010203u) != 0);- In
Convert.c:1374:
DefaultAllocator alloc = DefaultAllocatorInit();
Int out = IntInit(&alloc.base);
bool parsed = IntTryFromBinary(&out, "0c1");- In
Convert.c:1391:
DefaultAllocator alloc = DefaultAllocatorInit();
Int out = IntInit(&alloc.base);
bool parsed = IntTryFromBinary(&out, "0b101");- In
Convert.c:1414:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFromBytesLE(NULL, 0, ALLOCATOR_OF(&alloc));
bool result = IntIsZero(&value);- In
Convert.c:1436:
u8 bytes[] = {0x05, 0x00};
Int value = IntFromBytesLE(bytes, sizeof(bytes), ALLOCATOR_OF(&alloc));
bool result = (IntToU64(&value) == 5);- In
Convert.c:1458:
Str digits = StrInitFromZstr("12345", &alloc.base);
Int value = IntFromStr(&digits, &alloc.base);
bool result = (IntToU64(&value) == (u64)12345u);- In
Convert.c:1479:
Str digits = StrInitFromZstr("ff", &alloc.base);
Int value = IntFromStrRadix(&digits, (u8)16u, &alloc.base);
bool result = (IntToU64(&value) == (u64)255u);- In
Convert.c:1503:
Str hex = StrInitFromZstr("ff", &alloc.base);
Int value = IntInit(&alloc.base);
bool ok = int_try_from_hex_str_str(&value, &hex);- In
Convert.c:1528:
Str hex = StrInitFromZstr("12g3", &alloc.base);
Int value = IntInit(&alloc.base);
bool ok = int_try_from_hex_str_str(&value, &hex);- In
Convert.c:1551:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(0x0102, &alloc.base);
u8 buf[4];
MemSet(buf, 0xAA, sizeof(buf));- In
Convert.c:1572:
// Drives int_try_to_str_radix loop (760, 772) and int_div_u64_rem
// (1583/1584) and int_mod_u64 (1630).
Int v = IntFrom(1234567u, a);
Str s = IntToStrRadix(&v, 10, false, a);
bool ok = StrLen(&s) == 7;- In
Convert.c:1577:
u64 rem = 0;
{
Int q = IntInit(a);
rem = int_div_u64_rem(&q, &v, 1000u);
IntDeinit(&q);- In
Convert.c:1595:
u8 bytes[] = {0x01, 0x02, 0x03, 0x04};
Int v = IntFromBytesBE(bytes, sizeof(bytes), &dbg);
bool ok = IntToU64(&v) == 0x01020304u;- In
Convert.c:1609:
Allocator *a = ALLOCATOR_OF(&dbg);
Int out = IntFrom(987654321u, a); // pre-populated: holds a live buffer
bool ok = IntTryFromStr(&out, "123456789");- In
Convert.c:1624:
Allocator *alloc = ALLOCATOR_OF(&dbg);
Int value = IntFromStr("123456789012345678901234567890", alloc);
Str hex = IntToStrRadix(&value, 16, false, alloc);
Int parsed = IntFromStrRadix(&hex, 16, alloc);- In
Convert.c:1626:
Int value = IntFromStr("123456789012345678901234567890", alloc);
Str hex = IntToStrRadix(&value, 16, false, alloc);
Int parsed = IntFromStrRadix(&hex, 16, alloc);
bool ok = IntCompare(&value, &parsed) == 0;- In
Convert.c:1640:
int main(void) {
WriteFmt("[INFO] Starting Int.Convert tests\n\n");
TestFunction tests[] = {- In
Convert.c:1730:
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
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
Access.c:32:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFromBinary("00101000", &alloc.base);
bool result = IntBitLength(&value) == 6;- In
Access.c:46:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFromBinary("0001001000110100", &alloc.base);
bool result = IntByteLength(&value) == 2;- In
Access.c:60:
DefaultAllocator alloc = DefaultAllocatorInit();
Int zero = IntInit(&alloc.base);
Int non_zero = IntFrom(1, &alloc.base);- In
Access.c:61:
Int zero = IntInit(&alloc.base);
Int non_zero = IntFrom(1, &alloc.base);
bool result = IntIsZero(&zero);- In
Access.c:77:
DefaultAllocator alloc = DefaultAllocatorInit();
Int one = IntFrom(1, &alloc.base);
Int two = IntFrom(2, &alloc.base);- In
Access.c:78:
Int one = IntFrom(1, &alloc.base);
Int two = IntFrom(2, &alloc.base);
bool result = IntIsOne(&one);- In
Access.c:90:
bool test_int_parity(void) {
WriteFmt("Testing Int parity helpers\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Access.c:94:
DefaultAllocator alloc = DefaultAllocatorInit();
Int even = IntFrom(42, &alloc.base);
Int odd = IntFrom(43, &alloc.base);- In
Access.c:95:
Int even = IntFrom(42, &alloc.base);
Int odd = IntFrom(43, &alloc.base);
bool result = IntIsEven(&even);- In
Access.c:113:
DefaultAllocator alloc = DefaultAllocatorInit();
Int small = IntFrom(UINT64_MAX, &alloc.base);
Int big = IntFrom(1, &alloc.base);- In
Access.c:114:
Int small = IntFrom(UINT64_MAX, &alloc.base);
Int big = IntFrom(1, &alloc.base);
IntShiftLeft(&big, 64);- In
Access.c:132:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(1025, &alloc.base);
bool error = true;- In
Access.c:148:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFromBinary("1010000", &alloc.base);
Int zero = IntInit(&alloc.base);- In
Access.c:149:
Int value = IntFromBinary("1010000", &alloc.base);
Int zero = IntInit(&alloc.base);
bool result = IntTrailingZeroCount(&value) == 4;- In
Access.c:165:
DefaultAllocator alloc = DefaultAllocatorInit();
Int one = IntFrom(1, &alloc.base);
Int power = IntFrom(1, &alloc.base);
Int other = IntFrom(24, &alloc.base);- In
Access.c:166:
Int one = IntFrom(1, &alloc.base);
Int power = IntFrom(1, &alloc.base);
Int other = IntFrom(24, &alloc.base);
Int zero = IntInit(&alloc.base);- In
Access.c:167:
Int one = IntFrom(1, &alloc.base);
Int power = IntFrom(1, &alloc.base);
Int other = IntFrom(24, &alloc.base);
Int zero = IntInit(&alloc.base);- In
Access.c:168:
Int power = IntFrom(1, &alloc.base);
Int other = IntFrom(24, &alloc.base);
Int zero = IntInit(&alloc.base);
IntShiftLeft(&power, 20);- In
Access.c:190:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntInit(&alloc.base);
bool error = false;- In
Access.c:210:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(12345, &alloc.base);
Int root = IntFrom(99, &alloc.base);
Int remainder = IntFrom(77, &alloc.base);- In
Access.c:211:
Int value = IntFrom(12345, &alloc.base);
Int root = IntFrom(99, &alloc.base);
Int remainder = IntFrom(77, &alloc.base);- In
Access.c:212:
Int value = IntFrom(12345, &alloc.base);
Int root = IntFrom(99, &alloc.base);
Int remainder = IntFrom(77, &alloc.base);
bool ok = IntRootRem(&root, &remainder, &value, 1);- In
Access.c:234:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(0, &alloc.base);
u64 h = int_hash(&value, 0);- In
Access.c:253:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(255, &alloc.base);
u64 expected = 1469598103934665603ULL;- In
Access.c:275:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(5, &alloc.base);
bool ok = IntShiftRight(&value, 0);- In
Access.c:298:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom(7u, &alloc.base);
bool ok = IntShiftLeft(&value, 0);- In
Access.c:319:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFrom((u64)40u, &alloc.base);
bool result = (IntBitLength(&value) == 6u);- In
Access.c:338:
///
static bool test_m28_bit_length_invalid_deadend(void) {
WriteFmt("Testing IntBitLength validation on invalid Int\n");
Int invalid = {0};- In
Access.c:340:
WriteFmt("Testing IntBitLength validation on invalid Int\n");
Int invalid = {0};
(void)IntBitLength(&invalid);- In
Access.c:355:
DefaultAllocator alloc = DefaultAllocatorInit();
Int base = IntFrom(7, &alloc.base);
Int mod = IntFrom(13, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Access.c:356:
Int base = IntFrom(7, &alloc.base);
Int mod = IntFrom(13, &alloc.base);
Int result_value = IntInit(&alloc.base);- In
Access.c:357:
Int base = IntFrom(7, &alloc.base);
Int mod = IntFrom(13, &alloc.base);
Int result_value = IntInit(&alloc.base);
bool ok = IntPowMod(&result_value, &base, 20u, &mod);- In
Access.c:371:
int main(void) {
WriteFmt("[INFO] Starting Int.Access tests\n\n");
TestFunction tests[] = {- In
Access.c:399:
int total_tests = sizeof(tests) / sizeof(tests[0]);
int total_deadend_tests = sizeof(deadend_tests) / sizeof(deadend_tests[0]);
return run_test_suite(tests, total_tests, deadend_tests, total_deadend_tests, "Int.Access");
}- In
Write.c:6:
#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
Write.c:593:
bool test_int_formatting(void) {
WriteFmt("Testing Int formatting\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Write.c:601:
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
Write.c:602:
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
Write.c:603:
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
Write.c:604:
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
Write.c:3229:
Str output = StrInit(&alloc);
Int a = IntFrom(0x41, alloc_base); // 'A'
bool success = true;- In
Write.c:3248:
Str output = StrInit(&alloc);
Int a = IntFrom(0x7a, alloc_base); // 'z'
bool success = true;- In
Write.c:3273:
Str output = StrInit(&alloc);
Int seven = IntFrom(7, alloc_base);
bool success = true;- In
Write.c:3820:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Int oct = IntInit(alloc_base);
Zstr z = "78";- In
Write.c:4405:
DefaultAllocator alloc = DefaultAllocatorInit();
Int v = IntInit(ALLOCATOR_OF(&alloc));
Zstr z = "9z";
StrReadFmt(z, "{}", v);- In
Write.c:4422:
DefaultAllocator alloc = DefaultAllocatorInit();
Int v = IntInit(ALLOCATOR_OF(&alloc));
Zstr z = "5";
StrReadFmt(z, "{}", v);- In
Write.c:4438:
DefaultAllocator alloc = DefaultAllocatorInit();
Int v = IntInit(ALLOCATOR_OF(&alloc));
Zstr z = "+8";
StrReadFmt(z, "{}", v);- In
Write.c:4454:
DefaultAllocator alloc = DefaultAllocatorInit();
Int v = IntFromStr("123", &alloc);
Zstr z = "9_";
StrReadFmt(z, "{}", v);- In
Write.c:4471:
DefaultAllocator alloc = DefaultAllocatorInit();
Int v = IntFromStr("200", &alloc);
Zstr z = "0xFF";
StrReadFmt(z, "{x}", v);- In
Write.c:4487:
DefaultAllocator alloc = DefaultAllocatorInit();
Int v = IntFromStr("200", &alloc);
Zstr z = "0XFF";
StrReadFmt(z, "{x}", v);- In
Write.c:4502:
DefaultAllocator alloc = DefaultAllocatorInit();
Int v = IntInit(ALLOCATOR_OF(&alloc));
Zstr z = "ff";
StrReadFmt(z, "{x}", v);- In
Write.c:4517:
DefaultAllocator alloc = DefaultAllocatorInit();
Int v = IntFromStr("5", &alloc);
Zstr z = "0b1";
StrReadFmt(z, "{b}", v);- In
Write.c:4531:
DefaultAllocator alloc = DefaultAllocatorInit();
Int v = IntFromStr("5", &alloc);
Zstr z = "0B1";
StrReadFmt(z, "{b}", v);- In
Write.c:4545:
DefaultAllocator alloc = DefaultAllocatorInit();
Int v = IntInit(ALLOCATOR_OF(&alloc));
Zstr z = "101";
StrReadFmt(z, "{b}", v);- In
Write.c:4560:
DefaultAllocator alloc = DefaultAllocatorInit();
Int v = IntFromStr("9", &alloc);
Zstr z = "0o7";
StrReadFmt(z, "{o}", v);- In
Write.c:4574:
DefaultAllocator alloc = DefaultAllocatorInit();
Int v = IntFromStr("9", &alloc);
Zstr z = "0O7";
StrReadFmt(z, "{o}", v);- In
Write.c:4588:
DefaultAllocator alloc = DefaultAllocatorInit();
Int v = IntInit(ALLOCATOR_OF(&alloc));
Zstr z = "17";
StrReadFmt(z, "{o}", v);- In
Write.c:4603:
DefaultAllocator alloc = DefaultAllocatorInit();
Int v = IntInit(ALLOCATOR_OF(&alloc));
Zstr z = " 42";
StrReadFmt(z, "{}", v);- In
Write.c:5437:
static bool test_int_write_no_leak(void) {
DBG_BEGIN(dbg, out);
Int v = IntFromStr("123456789012345678901234567890", &dbg.base);
StrAppendFmt(&out, "{}", v);
bool ok = (ZstrCompare(StrBegin(&out), "123456789012345678901234567890") == 0);- In
Write.c:5449:
Allocator *ab = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
Int v = IntFrom(42, ab);
StrAppendFmt(&out, "{}", v);
bool ok = (ZstrCompare(StrBegin(&out), "42") == 0);- In
Write.c:5689:
bool test_leak_write_int_freed(void) {
HeapAllocator va = HeapAllocatorInit();
Int v = IntFromStr("123456789012345678901234567890", ALLOCATOR_OF(&va));
LEAK_WRITE_PRELUDE();
ok = ok && StrAppendFmt(&out, "{}", v) && (StrLen(&out) > 0);- In
Read.c:6:
#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/Container/Buf.h>- In
Read.c:907:
bool test_int_reading(void) {
WriteFmt("Testing Int reading\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Read.c:915:
bool success = true;
Int dec = IntInit(alloc_base);
Int hex = IntInit(alloc_base);
Int bin = IntInit(alloc_base);- In
Read.c:916:
Int dec = IntInit(alloc_base);
Int hex = IntInit(alloc_base);
Int bin = IntInit(alloc_base);
Int oct = IntInit(alloc_base);- In
Read.c:917:
Int dec = IntInit(alloc_base);
Int hex = IntInit(alloc_base);
Int bin = IntInit(alloc_base);
Int oct = IntInit(alloc_base);- In
Read.c:918:
Int hex = IntInit(alloc_base);
Int bin = IntInit(alloc_base);
Int oct = IntInit(alloc_base);
Str dec_text = StrInit(&alloc);- In
Read.c:2565:
static bool test_read_int_plain(void) {
DebugAllocator dbg = DebugAllocatorInit();
Int v = IntInit(&dbg.base);
Zstr z = "12345";
StrReadFmt(z, "{}", v);- In
Read.c:2580:
static bool test_read_int_leading_plus(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Int v = IntInit(&alloc.base);
Zstr z = "+99";
StrReadFmt(z, "{}", v);- In
Read.c:2596:
static bool test_read_int_hex_plain(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Int v = IntInit(&alloc.base);
Zstr z = "ff";
StrReadFmt(z, "{x}", v);- In
Read.c:2612:
static bool test_read_int_underscore_rejected(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Int v = IntFrom(777, &alloc.base);
Zstr z = "12_3";
Zstr out = str_read_fmt(z, "{}", (TypeSpecificIO[]) {TO_TYPE_SPECIFIC_IO(Int, &v)}, 1);- In
Read.c:2614:
Int v = IntFrom(777, &alloc.base);
Zstr z = "12_3";
Zstr out = str_read_fmt(z, "{}", (TypeSpecificIO[]) {TO_TYPE_SPECIFIC_IO(Int, &v)}, 1);
// Real: '_' rejected -> returns start (==z) -> str_read_fmt sees next==in ->
// NULL; v unchanged (still 777).
- In
Read.c:2821:
// Seed the destination with a heap-backed Int (multi-limb) so the old
// storage is visible in dbg's live count before the reassignment.
Int value = IntFromStr("123456789012345678901234567890", adbg);
Zstr input = "42";
Last updated on