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 › pow Public Function pow Doc Source Public Function std.math.big.int.Managed.pow
pub fn pow (rma : *Managed , a : *const Managed , b : u32 ) !void Params File math/big/int.zig: 3542
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565 pub fn pow (rma : *Managed , a : *const Managed , b : u32 ) !void {
const needed_limbs = calcPowLimbsBufferLen (a .bitCountAbs (), b );
const capacity_alias = limbsAliasDistinct (rma , a );
const same_buffer = rma .limbs .ptr == a .limbs .ptr ;
try rma .ensureAliasAwareCapacity (needed_limbs , capacity_alias );
const limbs_buffer = try rma .allocator .alloc (Limb , needed_limbs );
defer rma .allocator .free (limbs_buffer );
if (same_buffer ) {
const a_len = a .len ();
const tmp = try rma .allocator .alloc (Limb , a_len );
defer rma .allocator .free (tmp );
@memcpy (tmp [0 ..a_len ], a .limbs [0 ..a_len ]);
const a_const : Const = .{ .limbs = tmp [0 ..a_len ], .positive = a .isPositive () };
var rma_mut = rma .toMutable ();
rma_mut .pow (a_const , b , limbs_buffer );
rma .setMetadata (rma_mut .positive , rma_mut .len );
} else {
var rma_mut = rma .toMutable ();
rma_mut .pow (a .toConst (), b , limbs_buffer );
rma .setMetadata (rma_mut .positive , rma_mut .len );
}
}