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

divTrunc

Public Function
std.math.big.int.Managed.divTrunc
pub fn divTrunc(q: *Managed, r: *Managed, a: *const Managed, b: *const Managed) !void

q = a / b (rem r)

a / b are truncated (rounded towards -inf).

Returns an error if memory could not be allocated.

Params

File

math/big/int.zig:3397
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
    pub fn divTrunc(q: *Managed, r: *Managed, a: *const Managed, b: *const Managed) !void {
        const q_alias = limbsAliasDistinct(q, a) or limbsAliasDistinct(q, b);
        const r_alias = limbsAliasDistinct(r, a) or limbsAliasDistinct(r, b);
        try q.ensureAliasAwareCapacity(a.len(), q_alias);
        try r.ensureAliasAwareCapacity(b.len(), r_alias);
        var mq = q.toMutable();
        var mr = r.toMutable();
        const limbs_buffer = try q.allocator.alloc(Limb, calcDivLimbsBufferLen(a.len(), b.len()));
        defer q.allocator.free(limbs_buffer);
        mq.divTrunc(&mr, a.toConst(), b.toConst(), limbs_buffer);
        q.setMetadata(mq.positive, mq.len);
        r.setMetadata(mr.positive, mr.len);
    }