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 Namespace

Backend128_Tables

Public Namespace
std.fmt.float.Backend128_Tables
pub const Backend128_Tables = struct

Values

Functions

fn mulShift128(m: u128, mul: *const [4]u64, j: u32) u128
fn computePow5(i: u32) [4]u64
fn computeInvPow5(i: u32) [4]u64

File

fmt/float.zig:632
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
pub const Backend128_Tables = struct {
    const T = u128;
    const mulShift = mulShift128;
    const POW5_INV_BITCOUNT = FLOAT128_POW5_INV_BITCOUNT;
    const POW5_BITCOUNT = FLOAT128_POW5_BITCOUNT;

    const bound1 = 55;
    const bound2 = 127;
    const adjust_q = true;

    fn computePow5(i: u32) [4]u64 {
        const base = i / FLOAT128_POW5_TABLE_SIZE;
        const base2 = base * FLOAT128_POW5_TABLE_SIZE;
        const mul = &FLOAT128_POW5_SPLIT[base];
        if (i == base2) {
            return mul.*;
        } else {
            const offset = i - base2;
            const m = &FLOAT128_POW5_TABLE[offset];
            const delta = pow5Bits(i) - pow5Bits(base2);

            const shift: u6 = @intCast(2 * (i % 32));
            const corr: u32 = @intCast((FLOAT128_POW5_ERRORS[i / 32] >> shift) & 3);
            return mul_128_256_shift(m, mul, delta, corr);
        }
    }

    fn computeInvPow5(i: u32) [4]u64 {
        const base = (i + FLOAT128_POW5_TABLE_SIZE - 1) / FLOAT128_POW5_TABLE_SIZE;
        const base2 = base * FLOAT128_POW5_TABLE_SIZE;
        const mul = &FLOAT128_POW5_INV_SPLIT[base]; // 1 / 5^base2
        if (i == base2) {
            return .{ mul[0] + 1, mul[1], mul[2], mul[3] };
        } else {
            const offset = base2 - i;
            const m = &FLOAT128_POW5_TABLE[offset]; // 5^offset
            const delta = pow5Bits(base2) - pow5Bits(i);

            const shift: u6 = @intCast(2 * (i % 32));
            const corr: u32 = @intCast(((FLOAT128_POW5_INV_ERRORS[i / 32] >> shift) & 3) + 1);
            return mul_128_256_shift(m, mul, delta, corr);
        }
    }
}