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

parsePartialInfOrNan

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

Params

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

File

fmt/parse_float/parse.zig:249
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
fn parsePartialInfOrNan(comptime T: type, s: []const u8, negative: bool, n: *usize) ?T {
    // inf/infinity; infxxx should only consume inf.
    if (std.ascii.startsWithIgnoreCase(s, "inf")) {
        n.* = 3;
        if (std.ascii.startsWithIgnoreCase(s[3..], "inity")) {
            n.* = 8;
        }

        return if (!negative) std.math.inf(T) else -std.math.inf(T);
    }

    if (std.ascii.startsWithIgnoreCase(s, "nan")) {
        n.* = 3;
        return std.math.nan(T);
    }

    return null;
}