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
Parse the significant digits and biased, binary exponent of a float.
This is a fallback algorithm that uses a big-integer representation of the float, and therefore is considerably slower than faster approximations. However, it will always determine how to round the significant digits to the nearest machine float, allowing use to handle near half-way cases.
Near half-way cases are halfway between two consecutive machine floats. For example, the float 16777217.0 has a bitwise representation of 100000000000000000000000 1. Rounding to a single-precision float, the trailing 1 is truncated. Using round-nearest, tie-even, any value above 16777217.0 must be rounded up to 16777218.0, while any value before or equal to 16777217.0 must be rounded down to 16777216.0. These near-halfway conversions therefore may require a large number of digits to unambiguously determine how to round.
Parse the significant digits and biased, binary exponent of a float.
This is a fallback algorithm that uses a big-integer representation of the float, and therefore is considerably slower than faster approximations. However, it will always determine how to round the significant digits to the nearest machine float, allowing use to handle near half-way cases.
Near half-way cases are halfway between two consecutive machine floats. For example, the float
16777217.0has a bitwise representation of100000000000000000000000 1. Rounding to a single-precision float, the trailing1is truncated. Using round-nearest, tie-even, any value above16777217.0must be rounded up to16777218.0, while any value before or equal to16777217.0must be rounded down to16777216.0. These near-halfway conversions therefore may require a large number of digits to unambiguously determine how to round.The algorithms described here are based on "Processing Long Numbers Quickly", available here: https://arxiv.org/pdf/2101.11408.pdf#section.11.
Note that this function needs a lot of stack space and is marked cold to hint against inlining into the caller.