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 › llmulLimb Private Function llmulLimb Doc Source Private Function std.math.big.int.llmulLimb
fn llmulLimb (comptime op : AccOp , acc : []Limb , y : []const Limb , xi : Limb ) bool Params File math/big/int.zig: 3916
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961 fn llmulLimb (comptime op : AccOp , acc : []Limb , y : []const Limb , xi : Limb ) bool {
assert (!slicesOverlap (acc , y ) or @intFromPtr (acc .ptr ) <= @intFromPtr (y .ptr ));
if (xi == 0 ) {
return false ;
}
const split = @min (y .len , acc .len );
var a_lo = acc [0 ..split ];
var a_hi = acc [split ..];
switch (op ) {
.add => {
var carry : Limb = 0 ;
var j : usize = 0 ;
while (j < a_lo .len ) : (j += 1 ) {
a_lo [j ] = addMulLimbWithCarry (a_lo [j ], y [j ], xi , &carry );
}
j = 0 ;
while ((carry != 0 ) and (j < a_hi .len )) : (j += 1 ) {
const ov = @addWithOverflow (a_hi [j ], carry );
a_hi [j ] = ov [0 ];
carry = ov [1 ];
}
return carry != 0 ;
},
.sub => {
var borrow : Limb = 0 ;
var j : usize = 0 ;
while (j < a_lo .len ) : (j += 1 ) {
a_lo [j ] = subMulLimbWithBorrow (a_lo [j ], y [j ], xi , &borrow );
}
j = 0 ;
while ((borrow != 0 ) and (j < a_hi .len )) : (j += 1 ) {
const ov = @subWithOverflow (a_hi [j ], borrow );
a_hi [j ] = ov [0 ];
borrow = ov [1 ];
}
return borrow != 0 ;
},
}
}
r = r (op) y * xi The result is computed modulo
r.len. Returns whether the operation overflowed.