pub fn addMulLimbWithCarry(a: Limb, b: Limb, c: Limb, carry: *Limb) Limb
a + b * c + *carry, sets carry to the overflow bits.
- Kind
- function
- Module
std.math.big.int
pub fn calcDivLimbsBufferLen(a_len: usize, b_len: usize) usize
- Kind
- function
- Module
std.math.big.int
pub fn calcLimbLen(scalar: anytype) usize
Returns the number of limbs needed to store `scalar`, which must be a primitive integer or float value.
- Kind
- function
- Module
std.math.big.int
pub fn calcLog10LimbsBufferLen(a_len: usize) usize
Same as `calcToStringLimbsBufferLen`, without the useless base check.
- Kind
- function
- Module
std.math.big.int
pub fn calcMulLimbsBufferLen(a_len: usize, b_len: usize, aliases: usize) usize
- Kind
- function
- Module
std.math.big.int
pub fn calcMulWrapLimbsBufferLen(bit_count: usize, a_len: usize, b_len: usize, aliases: usize) usize
- Kind
- function
- Module
std.math.big.int
pub fn calcNonZeroTwosCompLimbCount(bit_count: usize) usize
Compute the number of limbs required to store a 2s-complement number of `bit_count` bits.
- Kind
- function
- Module
std.math.big.int
pub fn calcPowLimbsBufferLen(a_bit_count: usize, y: usize) usize
- Kind
- function
- Module
std.math.big.int
pub fn calcSetStringLimbCount(base: u8, string_len: usize) usize
Assumes `string_len` doesn't account for minus signs if the number is negative.
- Kind
- function
- Module
std.math.big.int
pub fn calcSetStringLimbsBufferLen(base: u8, string_len: usize) usize
- Kind
- function
- Module
std.math.big.int
pub fn calcSqrtLimbsBufferLen(a_bit_count: usize) usize
- Kind
- function
- Module
std.math.big.int
pub fn calcToStringLimbsBufferLen(a_len: usize, base: u8) usize
- Kind
- function
- Module
std.math.big.int
pub fn calcTwosCompLimbCount(bit_count: usize) usize
Compute the number of limbs required to store a 2s-complement number of `bit_count` bits.
- Kind
- function
- Module
std.math.big.int
A arbitrary-precision big integer, with a fixed set of immutable limbs.
- Kind
- struct
- Module
std.math.big.int
pub fn abs(self: Const) Const
- Kind
- function
- Module
std.math.big.int
pub fn bitCountAbs(self: Const) usize
Returns the number of bits required to represent the absolute value of an integer.
- Kind
- function
- Module
std.math.big.int
pub fn bitCountTwosComp(self: Const) usize
Returns the number of bits required to represent the integer in twos-complement form.
- Kind
- function
- Module
std.math.big.int
pub fn bitCountTwosCompForSignedness(self: Const, signedness: std.builtin.Signedness) usize
Returns the number of bits required to represent the integer in twos-complement form with the given signedness.
- Kind
- function
- Module
std.math.big.int
pub fn clz(a: Const, bits: Limb) Limb
Returns the number of leading zeros in twos-complement form.
- Kind
- function
- Module
std.math.big.int
- Kind
- error set
- Module
std.math.big.int
pub fn ctz(a: Const, bits: Limb) Limb
Returns the number of trailing zeros in twos-complement form.
- Kind
- function
- Module
std.math.big.int
pub fn dump(self: Const) void
- Kind
- function
- Module
std.math.big.int
pub fn eql(a: Const, b: Const) bool
Returns true if `a == b`.
- Kind
- function
- Module
std.math.big.int
pub fn eqlAbs(a: Const, b: Const) bool
Returns true if `|a| == |b|`.
- Kind
- function
- Module
std.math.big.int
pub fn eqlZero(a: Const) bool
Returns true if `a == 0`.
- Kind
- function
- Module
std.math.big.int
pub fn fits(self: Const, comptime T: type) bool
Returns whether self can fit into an integer of the requested type.
- Kind
- function
- Module
std.math.big.int
pub fn fitsInTwosComp(self: Const, signedness: Signedness, bit_count: usize) bool
- Kind
- function
- Module
std.math.big.int
pub fn format(self: Const, w: *std.Io.Writer) std.Io.Writer.Error!void
- Kind
- function
- Module
std.math.big.int
pub fn formatNumber(self: Const, w: *std.Io.Writer, number: std.fmt.Number) std.Io.Writer.Error!void
If the absolute value of integer is greater than or equal to `pow(2, 64 * @sizeOf(usize) * 8)`, this function will fail to print the string, printing "(BigInt)" instead of a number.
- Kind
- function
- Module
std.math.big.int
pub fn isEven(self: Const) bool
- Kind
- function
- Module
std.math.big.int
pub fn isOdd(self: Const) bool
- Kind
- function
- Module
std.math.big.int
pub fn log2(a: Const) Limb
Calculate the base 2 logarithm, rounded down.
- Kind
- function
- Module
std.math.big.int
pub fn log10(a: Const, limbs_buffer: []Limb) Limb
Calculate the base 10 logarithm, rounded down. `limbs_buffer` is used for temporary storage.
- Kind
- function
- Module
std.math.big.int
pub fn log10Alloc(a: Const, allocator: Allocator) Allocator.Error!Limb
Calculate the base 10 logarithm, rounded down.
- Kind
- function
- Module
std.math.big.int
pub fn negate(self: Const) Const
- Kind
- function
- Module
std.math.big.int
pub fn order(a: Const, b: Const) math.Order
Returns `math.Order.lt`, `math.Order.eq`, `math.Order.gt` if `a < b`, `a == b` or `a > b` respectively.
- Kind
- function
- Module
std.math.big.int
pub fn orderAbs(a: Const, b: Const) math.Order
Returns `math.Order.lt`, `math.Order.eq`, `math.Order.gt` if `|a| < |b|`, `|a| == |b|`, or `|a| > |b|` respectively.
- Kind
- function
- Module
std.math.big.int
pub fn orderAgainstScalar(lhs: Const, scalar: anytype) math.Order
Same as `order` but the right-hand operand is a primitive integer.
- Kind
- function
- Module
std.math.big.int
pub fn popCount(self: Const, bit_count: usize) usize
@popCount with two's complement semantics.
- Kind
- function
- Module
std.math.big.int
pub fn sizeInBaseUpperBound(self: Const, base: usize) usize
Returns the approximate size of the integer in the given base.
- Kind
- function
- Module
std.math.big.int
pub fn toFloat(self: Const, comptime Float: type, round: Round) struct
Convert self to `Float`.
- Kind
- function
- Module
std.math.big.int
pub fn toInt(self: Const, comptime Int: type) ConvertError!Int
Convert `self` to `Int`.
- Kind
- function
- Module
std.math.big.int
pub fn toManaged(self: Const, allocator: Allocator) Allocator.Error!Managed
The result is an independent resource which is managed by the caller.
- Kind
- function
- Module
std.math.big.int
pub fn toMutable(self: Const, limbs: []Limb) Mutable
- Kind
- function
- Module
std.math.big.int
pub fn toString(self: Const, string: []u8, base: u8, case: std.fmt.Case, limbs_buffer: []Limb) usize
Converts self to a string in the requested base.
- Kind
- function
- Module
std.math.big.int
pub fn toStringAlloc(self: Const, allocator: Allocator, base: u8, case: std.fmt.Case) Allocator.Error![]u8
Converts self to a string in the requested base.
- Kind
- function
- Module
std.math.big.int
pub fn writePackedTwosComplement(x: Const, buffer: []u8, bit_offset: usize, bit_count: usize, endian: Endian) void
Write the value of `x` to a packed memory `buffer`.
- Kind
- function
- Module
std.math.big.int
pub fn writeTwosComplement(x: Const, buffer: []u8, endian: Endian) void
Write the value of `x` into `buffer` Asserts that `buffer` is large enough to store the value. `buffer` is filled so that its contents match what would be observed via @ptrCast(*[buffer.len]const u8, &x).
- Kind
- function
- Module
std.math.big.int
- Kind
- type
- Module
std.math.big.int
pub fn llcmp(a: []const Limb, b: []const Limb) i8
Returns -1, 0, 1 if |a| < |b|, |a| == |b| or |a| > |b| respectively for limbs.
- Kind
- function
- Module
std.math.big.int
An arbitrary-precision big integer along with an allocator which manages the memory.
- Kind
- struct
- Module
std.math.big.int
pub fn abs(self: *Managed) void
Make positive.
- Kind
- function
- Module
std.math.big.int
pub fn add(r: *Managed, a: *const Managed, b: *const Managed) Allocator.Error!void
r = a + b r, a and b may be aliases.
- Kind
- function
- Module
std.math.big.int
pub fn addSat(r: *Managed, a: *const Managed, b: *const Managed, signedness: Signedness, bit_count: usize) Allocator.Error!void
r = a + b with 2s-complement saturating semantics. r, a and b may be aliases.
- Kind
- function
- Module
std.math.big.int
pub fn addScalar(r: *Managed, a: *const Managed, scalar: anytype) Allocator.Error!void
r = a + scalar r and a may be aliases.
- Kind
- function
- Module
std.math.big.int
pub fn addWrap(r: *Managed, a: *const Managed, b: *const Managed, signedness: Signedness, bit_count: usize) Allocator.Error!bool
r = a + b with 2s-complement wrapping semantics.
- Kind
- function
- Module
std.math.big.int
pub fn bitAnd(r: *Managed, a: *const Managed, b: *const Managed) !void
- Kind
- function
- Module
std.math.big.int
pub fn bitCountAbs(self: Managed) usize
Returns the number of bits required to represent the absolute value of an integer.
- Kind
- function
- Module
std.math.big.int
pub fn bitCountTwosComp(self: Managed) usize
Returns the number of bits required to represent the integer in twos-complement form.
- Kind
- function
- Module
std.math.big.int
pub fn bitNotWrap(r: *Managed, a: *const Managed, signedness: Signedness, bit_count: usize) !void
r = ~a under 2s-complement wrapping semantics. r and a may alias.
- Kind
- function
- Module
std.math.big.int
pub fn bitOr(r: *Managed, a: *const Managed, b: *const Managed) !void
r = a | b a and b are zero-extended to the longer of a or b.
- Kind
- function
- Module
std.math.big.int
pub fn bitXor(r: *Managed, a: *const Managed, b: *const Managed) !void
- Kind
- function
- Module
std.math.big.int
pub fn clone(other: Managed) !Managed
Returns a `Managed` with the same value.
- Kind
- function
- Module
std.math.big.int
pub fn cloneWithDifferentAllocator(other: Managed, allocator: Allocator) !Managed
- Kind
- function
- Module
std.math.big.int
- Kind
- type
- Module
std.math.big.int
pub fn copy(self: *Managed, other: Const) !void
Copies the value of the integer to an existing `Managed` so that they both have the same value.
- Kind
- function
- Module
std.math.big.int
Default number of limbs to allocate on creation of a `Managed`.
- Kind
- constant
- Module
std.math.big.int
pub fn deinit(self: *Managed) void
Frees all associated memory.
- Kind
- function
- Module
std.math.big.int
pub fn divCeil(q: *Managed, r: *Managed, a: *const Managed, b: *const Managed) !void
q = a / b (rem r) a / b are ceiled (rounded towards positive infinity).
- Kind
- function
- Module
std.math.big.int
pub fn divFloor(q: *Managed, r: *Managed, a: *const Managed, b: *const Managed) !void
q = a / b (rem r) a / b are floored (rounded towards 0).
- Kind
- function
- Module
std.math.big.int
pub fn divTrunc(q: *Managed, r: *Managed, a: *const Managed, b: *const Managed) !void
q = a / b (rem r) a / b are truncated (rounded towards -inf).
- Kind
- function
- Module
std.math.big.int
pub fn dump(self: Managed) void
Debugging tool: prints the state to stderr.
- Kind
- function
- Module
std.math.big.int
pub fn ensureAddCapacity(r: *Managed, a: *const Managed, b: *const Managed) !void
Use this function before doing `add` if some of your parameters alias each other.
- Kind
- function
- Module
std.math.big.int
pub fn ensureAddScalarCapacity(r: *Managed, a: *const Managed, scalar: anytype) !void
Use this function before doing `addScalar` if some of your parameters alias each other.
- Kind
- function
- Module
std.math.big.int
pub fn ensureCapacity(self: *Managed, capacity: usize) !void
Ensures an Managed has enough space allocated for capacity limbs.
- Kind
- function
- Module
std.math.big.int
pub fn ensureMulCapacity(rma: *Managed, a: *const Managed, b: *const Managed) !void
Use this function before doing `mul` if some of your parameters alias each other.
- Kind
- function
- Module
std.math.big.int
pub fn ensureTwosCompCapacity(r: *Managed, bit_count: usize) !void
- Kind
- function
- Module
std.math.big.int
pub fn eql(a: Managed, b: Managed) bool
Returns true if a == b.
- Kind
- function
- Module
std.math.big.int
pub fn eqlAbs(a: Managed, b: Managed) bool
Returns true if |a| == |b|.
- Kind
- function
- Module
std.math.big.int
pub fn eqlZero(a: Managed) bool
Returns true if a == 0.
- Kind
- function
- Module
std.math.big.int
pub fn fits(self: Managed, comptime T: type) bool
Returns whether self can fit into an integer of the requested type.
- Kind
- function
- Module
std.math.big.int
pub fn fitsInTwosComp(self: Managed, signedness: Signedness, bit_count: usize) bool
- Kind
- function
- Module
std.math.big.int
pub fn format(self: Managed, w: *std.Io.Writer) std.Io.Writer.Error!void
To allow `std.fmt.format` to work with `Managed`.
- Kind
- function
- Module
std.math.big.int
pub fn formatNumber(self: Managed, w: *std.Io.Writer, n: std.fmt.Number) std.Io.Writer.Error!void
If the absolute value of integer is greater than or equal to `pow(2, 64 * @sizeOf(usize) * 8)`, this function will fail to print the string, printing "(BigInt)" instead of a number.
- Kind
- function
- Module
std.math.big.int
pub fn gcd(rma: *Managed, x: *const Managed, y: *const Managed) !void
rma may alias x or y. x and y may alias each other. rma's allocator is used for temporary storage to boost multiplication performance.
- Kind
- function
- Module
std.math.big.int
pub fn init(allocator: Allocator) !Managed
Creates a new `Managed`. `default_capacity` limbs will be allocated immediately.
- Kind
- function
- Module
std.math.big.int
pub fn initCapacity(allocator: Allocator, capacity: usize) !Managed
Creates a new Managed with a specific capacity.
- Kind
- function
- Module
std.math.big.int
pub fn initSet(allocator: Allocator, value: anytype) !Managed
Creates a new `Managed` with value `value`.
- Kind
- function
- Module
std.math.big.int
pub fn isEven(self: Managed) bool
- Kind
- function
- Module
std.math.big.int
pub fn isOdd(self: Managed) bool
- Kind
- function
- Module
std.math.big.int
pub fn isPositive(self: Managed) bool
Returns whether an Managed is positive.
- Kind
- function
- Module
std.math.big.int
pub fn len(self: Managed) usize
Returns the number of limbs currently in use.
- Kind
- function
- Module
std.math.big.int
pub fn mul(rma: *Managed, a: *const Managed, b: *const Managed) !void
rma = a * b rma, a and b may be aliases.
- Kind
- function
- Module
std.math.big.int
pub fn mulWrap(rma: *Managed, a: *const Managed, b: *const Managed, signedness: Signedness, bit_count: usize) !void
rma = a * b with 2s-complement wrapping semantics. rma, a and b may be aliases.
- Kind
- function
- Module
std.math.big.int
pub fn negate(self: *Managed) void
Negate the sign.
- Kind
- function
- Module
std.math.big.int
pub fn normalize(r: *Managed, length: usize) void
Normalize a possible sequence of leading zeros. [1, 2, 3, 4, 0] -> [1, 2, 3, 4] [1, 2, 0, 0, 0] -> [1, 2] [0, 0, 0, 0, 0] -> [0].
- Kind
- function
- Module
std.math.big.int
pub fn order(a: Managed, b: Managed) math.Order
Returns math.Order.lt, math.Order.eq, math.Order.gt if a < b, a == b or a > b respectively.
- Kind
- function
- Module
std.math.big.int
pub fn orderAbs(a: Managed, b: Managed) math.Order
Returns math.Order.lt, math.Order.eq, math.Order.gt if |a| < |b|, |a| == |b| or |a| > |b| respectively.
- Kind
- function
- Module
std.math.big.int
pub fn popCount(r: *Managed, a: *const Managed, bit_count: usize) !void
r = @popCount(a) with 2s-complement semantics. r and a may be aliases.
- Kind
- function
- Module
std.math.big.int
pub fn pow(rma: *Managed, a: *const Managed, b: u32) !void
- Kind
- function
- Module
std.math.big.int
pub fn saturate(r: *Managed, a: *const Managed, signedness: Signedness, bit_count: usize) !void
r = saturate(Int(signedness, bit_count), a).
- Kind
- function
- Module
std.math.big.int
pub fn set(self: *Managed, value: anytype) Allocator.Error!void
Sets an Managed to value.
- Kind
- function
- Module
std.math.big.int
pub fn setLen(self: *Managed, new_len: usize) void
Sets the length of an Managed.
- Kind
- function
- Module
std.math.big.int
pub fn setMetadata(self: *Managed, positive: bool, length: usize) void
- Kind
- function
- Module
std.math.big.int
pub fn setSign(self: *Managed, positive: bool) void
Sets the sign of an Managed.
- Kind
- function
- Module
std.math.big.int
pub fn setString(self: *Managed, base: u8, value: []const u8) !void
Set self from the string representation `value`. `value` must contain only digits <= `base` and is case insensitive.
- Kind
- function
- Module
std.math.big.int
pub fn setTwosCompIntLimit(r: *Managed, limit: TwosCompIntLimit, signedness: Signedness, bit_count: usize) !void
Set self to either bound of a 2s-complement integer.
- Kind
- function
- Module
std.math.big.int
pub fn shiftLeft(r: *Managed, a: *const Managed, shift: usize) !void
r = a << shift, in other words, r = a * 2^shift r and a may alias.
- Kind
- function
- Module
std.math.big.int
pub fn shiftLeftSat(r: *Managed, a: *const Managed, shift: usize, signedness: Signedness, bit_count: usize) !void
r = a <<| shift with 2s-complement saturating semantics. r and a may alias.
- Kind
- function
- Module
std.math.big.int
pub fn shiftRight(r: *Managed, a: *const Managed, shift: usize) !void
r = a >> shift r and a may alias.
- Kind
- function
- Module
std.math.big.int
- Kind
- constant
- Module
std.math.big.int
pub fn sizeInBaseUpperBound(self: Managed, base: usize) usize
Returns the approximate size of the integer in the given base.
- Kind
- function
- Module
std.math.big.int
pub fn sqr(rma: *Managed, a: *const Managed) !void
- Kind
- function
- Module
std.math.big.int
pub fn sqrt(rma: *Managed, a: *const Managed) !void
- Kind
- function
- Module
std.math.big.int
pub fn sub(r: *Managed, a: *const Managed, b: *const Managed) !void
r = a - b r, a and b may be aliases.
- Kind
- function
- Module
std.math.big.int
pub fn subSat(r: *Managed, a: *const Managed, b: *const Managed, signedness: Signedness, bit_count: usize) Allocator.Error!void
r = a - b with 2s-complement saturating semantics. r, a and b may be aliases.
- Kind
- function
- Module
std.math.big.int
pub fn subWrap(r: *Managed, a: *const Managed, b: *const Managed, signedness: Signedness, bit_count: usize) Allocator.Error!bool
r = a - b with 2s-complement wrapping semantics.
- Kind
- function
- Module
std.math.big.int
pub fn swap(self: *Managed, other: *Managed) void
Efficiently swap a `Managed` with another.
- Kind
- function
- Module
std.math.big.int
pub fn toConst(self: Managed) Const
- Kind
- function
- Module
std.math.big.int
pub fn toFloat(self: Managed, comptime Float: type, round: Round) struct
Convert `self` to `Float`.
- Kind
- function
- Module
std.math.big.int
pub fn toInt(self: Managed, comptime Int: type) ConvertError!Int
Convert `self` to `Int`.
- Kind
- function
- Module
std.math.big.int
pub fn toMutable(self: Managed) Mutable
- Kind
- function
- Module
std.math.big.int
pub fn toString(self: Managed, allocator: Allocator, base: u8, case: std.fmt.Case) ![]u8
Converts self to a string in the requested base.
- Kind
- function
- Module
std.math.big.int
pub fn truncate(r: *Managed, a: *const Managed, signedness: Signedness, bit_count: usize) !void
r = truncate(Int(signedness, bit_count), a).
- Kind
- function
- Module
std.math.big.int
A arbitrary-precision big integer, with a fixed set of mutable limbs.
- Kind
- struct
- Module
std.math.big.int
pub fn abs(self: *Mutable) void
Modify to become the absolute value.
- Kind
- function
- Module
std.math.big.int
pub fn add(r: *Mutable, a: Const, b: Const) void
r = a + b r, a and b may be aliases.
- Kind
- function
- Module
std.math.big.int
pub fn addSat(r: *Mutable, a: Const, b: Const, signedness: Signedness, bit_count: usize) void
r = a + b with 2s-complement saturating semantics. r, a and b may be aliases.
- Kind
- function
- Module
std.math.big.int
pub fn addScalar(r: *Mutable, a: Const, scalar: anytype) void
r = a + scalar r and a may be aliases. scalar is a primitive integer type.
- Kind
- function
- Module
std.math.big.int
pub fn addWrap(r: *Mutable, a: Const, b: Const, signedness: Signedness, bit_count: usize) bool
r = a + b with 2s-complement wrapping semantics.
- Kind
- function
- Module
std.math.big.int
pub fn bitAnd(r: *Mutable, a: Const, b: Const) void
r = a & b under 2s complement semantics. r may alias with a or b.
- Kind
- function
- Module
std.math.big.int
pub fn bitNotWrap(r: *Mutable, a: Const, signedness: Signedness, bit_count: usize) void
r = ~a under 2s complement wrapping semantics. r may alias with a.
- Kind
- function
- Module
std.math.big.int
pub fn bitOr(r: *Mutable, a: Const, b: Const) void
r = a | b under 2s complement semantics. r may alias with a or b. a and b are zero-extended to the longer of a or b.
- Kind
- function
- Module
std.math.big.int
pub fn bitReverse(r: *Mutable, a: Const, signedness: Signedness, bit_count: usize) void
r = @bitReverse(a) with 2s-complement semantics. r and a may be aliases.
- Kind
- function
- Module
std.math.big.int
pub fn bitXor(r: *Mutable, a: Const, b: Const) void
r = a ^ b under 2s complement semantics. r may alias with a or b.
- Kind
- function
- Module
std.math.big.int
pub fn byteSwap(r: *Mutable, a: Const, signedness: Signedness, byte_count: usize) void
r = @byteSwap(a) with 2s-complement semantics. r and a may be aliases.
- Kind
- function
- Module
std.math.big.int
pub fn clone(other: Mutable, limbs: []Limb) Mutable
Clones an Mutable and returns a new Mutable with the same value.
- Kind
- function
- Module
std.math.big.int
- Kind
- type
- Module
std.math.big.int
pub fn copy(self: *Mutable, other: Const) void
Copies the value of a Const to an existing Mutable so that they both have the same value.
- Kind
- function
- Module
std.math.big.int
pub fn divCeil(q: *Mutable, r: *Mutable, a: Const, b: Const, limbs_buffer: []Limb) void
q = a / b (rem r) a / b are ceiled (rounded towards +inf). q may alias with a or b.
- Kind
- function
- Module
std.math.big.int
pub fn divFloor(q: *Mutable, r: *Mutable, a: Const, b: Const, limbs_buffer: []Limb) void
q = a / b (rem r) a / b are floored (rounded towards 0). q may alias with a or b.
- Kind
- function
- Module
std.math.big.int
pub fn divTrunc(q: *Mutable, r: *Mutable, a: Const, b: Const, limbs_buffer: []Limb) void
q = a / b (rem r) a / b are truncated (rounded towards -inf). q may alias with a or b.
- Kind
- function
- Module
std.math.big.int
pub fn dump(self: Mutable) void
- Kind
- function
- Module
std.math.big.int
pub fn eqlZero(self: Mutable) bool
Returns true if `a == 0`.
- Kind
- function
- Module
std.math.big.int
pub fn format(self: Mutable, w: *std.Io.Writer) std.Io.Writer.Error!void
- Kind
- function
- Module
std.math.big.int
pub fn formatNumber(self: Mutable, w: *std.Io.Writer, n: std.fmt.Number) std.Io.Writer.Error!void
If the absolute value of integer is greater than or equal to `pow(2, 64 * @sizeOf(usize) * 8)`, this function will fail to print the string, printing "(BigInt)" instead of a number.
- Kind
- function
- Module
std.math.big.int
pub fn gcd(rma: *Mutable, x: Const, y: Const, limbs_buffer: *std.array_list.Managed(Limb)) !void
rma may alias x or y. x and y may alias each other.
- Kind
- function
- Module
std.math.big.int
pub fn gcdNoAlias(rma: *Mutable, x: Const, y: Const, limbs_buffer: *std.array_list.Managed(Limb)) !void
rma may not alias x or y. x and y may alias each other.
- Kind
- function
- Module
std.math.big.int
pub fn init(limbs_buffer: []Limb, value: anytype) Mutable
`value` is a primitive integer type.
- Kind
- function
- Module
std.math.big.int
pub fn mul(rma: *Mutable, a: Const, b: Const, limbs_buffer: []Limb, allocator: ?Allocator) void
rma = a * b `rma` may alias with `a` or `b`. `a` and `b` may alias with each other.
- Kind
- function
- Module
std.math.big.int
pub fn mulNoAlias(rma: *Mutable, a: Const, b: Const, allocator: ?Allocator) void
rma = a * b `rma` may not alias with `a` or `b`. `a` and `b` may alias with each other.
- Kind
- function
- Module
std.math.big.int
pub fn mulWrap(rma: *Mutable, a: Const, b: Const, signedness: Signedness, bit_count: usize, limbs_buffer: []Limb, allocator: ?Allocator) void
rma = a * b with 2s-complement wrapping semantics. `rma` may alias with `a` or `b`. `a` and `b` may alias with each other.
- Kind
- function
- Module
std.math.big.int
pub fn mulWrapNoAlias(rma: *Mutable, a: Const, b: Const, signedness: Signedness, bit_count: usize, allocator: ?Allocator) void
rma = a * b with 2s-complement wrapping semantics. `rma` may not alias with `a` or `b`. `a` and `b` may alias with each other.
- Kind
- function
- Module
std.math.big.int
pub fn negate(self: *Mutable) void
- Kind
- function
- Module
std.math.big.int
pub fn normalize(r: *Mutable, length: usize) void
Normalize a possible sequence of leading zeros. [1, 2, 3, 4, 0] -> [1, 2, 3, 4] [1, 2, 0, 0, 0] -> [1, 2] [0, 0, 0, 0, 0] -> [0].
- Kind
- function
- Module
std.math.big.int
pub fn popCount(r: *Mutable, a: Const, bit_count: usize) void
r = @popCount(a) with 2s-complement semantics. r and a may be aliases.
- Kind
- function
- Module
std.math.big.int
pub fn pow(r: *Mutable, a: Const, b: u32, limbs_buffer: []Limb) void
q = a ^ b r may not alias a.
- Kind
- function
- Module
std.math.big.int
pub fn readPackedTwosComplement(x: *Mutable, buffer: []const u8, bit_offset: usize, bit_count: usize, endian: Endian, signedness: Signedness) void
Read the value of `x` from a packed memory `buffer`.
- Kind
- function
- Module
std.math.big.int
pub fn readTwosComplement(x: *Mutable, buffer: []const u8, bit_count: usize, endian: Endian, signedness: Signedness) void
Read the value of `x` from `buffer`.
- Kind
- function
- Module
std.math.big.int
pub fn saturate(r: *Mutable, a: Const, signedness: Signedness, bit_count: usize) void
Saturate an integer to a number of bits, following 2s-complement semantics. r may alias a.
- Kind
- function
- Module
std.math.big.int
pub fn set(self: *Mutable, value: anytype) void
Sets the Mutable to value.
- Kind
- function
- Module
std.math.big.int
pub fn setFloat(self: *Mutable, value: anytype, round: Round) Exactness
Sets the Mutable to a float value rounded according to `round`.
- Kind
- function
- Module
std.math.big.int
pub fn setString(self: *Mutable, base: u8, value: []const u8) error
Set self from the string representation `value`. `value` must contain only digits <= `base` and is case insensitive.
- Kind
- function
- Module
std.math.big.int
pub fn setTwosCompIntLimit(r: *Mutable, limit: TwosCompIntLimit, signedness: Signedness, bit_count: usize) void
Set self to either bound of a 2s-complement integer.
- Kind
- function
- Module
std.math.big.int
pub fn shiftLeft(r: *Mutable, a: Const, shift: usize) void
r = a << shift, in other words, r = a * 2^shift r and a may alias.
- Kind
- function
- Module
std.math.big.int
pub fn shiftLeftSat(r: *Mutable, a: Const, shift: usize, signedness: Signedness, bit_count: usize) void
r = a <<| shift with 2s-complement saturating semantics. r and a may alias.
- Kind
- function
- Module
std.math.big.int
pub fn shiftRight(r: *Mutable, a: Const, shift: usize) void
r = a >> shift r and a may alias.
- Kind
- function
- Module
std.math.big.int
pub fn sqrNoAlias(rma: *Mutable, a: Const, opt_allocator: ?Allocator) void
rma = a * a `rma` may not alias with `a`.
- Kind
- function
- Module
std.math.big.int
pub fn sqrt(r: *Mutable, a: Const, limbs_buffer: []Limb) void
r = ⌊√a⌋ r may alias a.
- Kind
- function
- Module
std.math.big.int
pub fn sub(r: *Mutable, a: Const, b: Const) void
r = a - b r, a and b may be aliases.
- Kind
- function
- Module
std.math.big.int
pub fn subSat(r: *Mutable, a: Const, b: Const, signedness: Signedness, bit_count: usize) void
r = a - b with 2s-complement saturating semantics. r, a and b may be aliases.
- Kind
- function
- Module
std.math.big.int
pub fn subWrap(r: *Mutable, a: Const, b: Const, signedness: Signedness, bit_count: usize) bool
r = a - b with 2s-complement wrapping semantics.
- Kind
- function
- Module
std.math.big.int
pub fn swap(self: *Mutable, other: *Mutable) void
Efficiently swap an Mutable with another.
- Kind
- function
- Module
std.math.big.int
pub fn toConst(self: Mutable) Const
- Kind
- function
- Module
std.math.big.int
pub fn toFloat(self: Mutable, comptime Float: type, round: Round) struct
Convert `self` to `Float`.
- Kind
- function
- Module
std.math.big.int
pub fn toInt(self: Mutable, comptime Int: type) ConvertError!Int
Convert `self` to `Int`.
- Kind
- function
- Module
std.math.big.int
pub fn toManaged(self: Mutable, allocator: Allocator) Managed
- Kind
- function
- Module
std.math.big.int
pub fn truncate(r: *Mutable, a: Const, signedness: Signedness, bit_count: usize) void
Truncate an integer to a number of bits, following 2s-complement semantics. `r` may alias `a`.
- Kind
- function
- Module
std.math.big.int
- Kind
- enum
- Module
std.math.big.int
Used to indicate either limit of a 2s-complement integer.
- Kind
- enum
- Module
std.math.big.int