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 › Managed › addSat Public Function addSat Doc Source Public Function std.math.big.int.Managed.addSat
pub fn addSat (r : *Managed , a : *const Managed , b : *const Managed , signedness : Signedness , bit_count : usize ) Allocator .Error !void Params File math/big/int.zig: 3188
3188
3189
3190
3191
3192
3193
3194
3195 pub fn addSat (r : *Managed , a : *const Managed , b : *const Managed , signedness : Signedness , bit_count : usize ) Allocator .Error !void {
const aliased = limbsAliasDistinct (r , a ) or limbsAliasDistinct (r , b );
const needed = calcTwosCompLimbCount (bit_count );
try r .ensureAliasAwareCapacity (needed , aliased );
var m = r .toMutable ();
m .addSat (a .toConst (), b .toConst (), signedness , bit_count );
r .setMetadata (m .positive , m .len );
}
r = a + b with 2s-complement saturating semantics.
r, a and b may be aliases.
Returns an error if memory could not be allocated.