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. Private Function

parsePartialNumber

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

Parse a partial, non-special floating point number.

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

Params

  • T: type
  • s: []const u8
  • negative: bool
  • n: *usize

File

fmt/parse_float/parse.zig:215
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
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',
        });
    }
}