Zig 0.17.0-dev (Split by item) This is an example of documentation generated by
ZigDoc , an alternative to Zig's built-in
Auto Doc feature. See also
examples in other modes/formats . The project being documented here (as the example) is the Zig standard library.
std › math › big › int › llmulacc Private Function llmulacc Doc Source Private Function std.math.big.int.llmulacc
fn llmulacc (comptime op : AccOp , opt_allocator : ?Allocator , r : []Limb , a : []const Limb , b : []const Limb ) void Params File math/big/int.zig: 3642
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668 fn llmulacc (comptime op : AccOp , opt_allocator : ?Allocator , r : []Limb , a : []const Limb , b : []const Limb ) void {
assert (r .len >= a .len );
assert (r .len >= b .len );
assert (!slicesOverlap (r , a ));
assert (!slicesOverlap (r , b ));
// Order greatest first.
var x = a ;
var y = b ;
if (a .len < b .len ) {
x = b ;
y = a ;
}
k_mul : {
if (y .len > 48 ) {
if (opt_allocator ) |allocator | {
llmulaccKaratsuba (op , allocator , r , x , y ) catch |err | switch (err ) {
error .OutOfMemory => break :k_mul , // handled below
};
return ;
}
}
}
llmulaccLong (op , r , x , y );
}
Knuth 4.3.1, Algorithm M.
r = r (op) a * b r MUST NOT alias any of a or b.
The result is computed modulo
r.len. Whenr.len >= a.len + b.len, no overflow occurs.