Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
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. Public Function

gcd

Public Function
std.math.big.int.Managed.gcd
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.

Params

File

math/big/int.zig:3508
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
    pub fn gcd(rma: *Managed, x: *const Managed, y: *const Managed) !void {
        const aliased = limbsAliasDistinct(rma, x) or limbsAliasDistinct(rma, y);
        const needed = @min(x.len(), y.len());
        try rma.ensureAliasAwareCapacity(needed, aliased);
        var m = rma.toMutable();
        var limbs_buffer = std.array_list.Managed(Limb).init(rma.allocator);
        defer limbs_buffer.deinit();
        try m.gcd(x.toConst(), y.toConst(), &limbs_buffer);
        rma.setMetadata(m.positive, m.len);
    }