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 library itself.

parsePartialNumber

Parse a partial, non-special floating point number.

This creates a representation of the float as the significant digits and the decimal exponent.

parse.parsePartialNumber
fn parsePartialNumber(comptime T: type, s: []const u8, negative: bool, n: *usize) ?Number(T)

File

Code

fn parsePartialNumber(comptime T: type, s: []const u8, negative: bool, n: *usize) ?Number(T) {
    std.debug.assert(s.len != 0);
    const MantissaT = common.mantissaType(T);
    n.* = 0;

    if (s.len >= 2 and s[0] == '0' and std.ascii.toLower(s[1]) == 'x') {
        var stream = FloatStream.init(s[2..]);
        n.* += 2;
        return parsePartialNumberBase(T, &stream, negative, n, .{
            .base = 16,
            .max_mantissa_digits = if (MantissaT == u64) 16 else 32,
            .exp_char_lower = 'p',
        });
    } else {
        var stream = FloatStream.init(s);
        return parsePartialNumberBase(T, &stream, negative, n, .{
            .base = 10,
            .max_mantissa_digits = if (MantissaT == u64) 19 else 38,
            .exp_char_lower = 'e',
        });
    }
}