fn parsePartialInfOrNan(comptime T: type, s: []const u8, negative: bool, n: *usize) ?T T: types: []const u8negative: booln: *usize249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266fn 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;
}