fn parseScientific(stream: *FloatStream) ?i64 stream: *FloatStream69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91fn parseScientific(stream: *FloatStream) ?i64 {
var exponent: i64 = 0;
var negative = false;
if (stream.first()) |c| {
negative = c == '-';
if (c == '-' or c == '+') {
stream.advance(1);
}
}
if (stream.firstIsDigit(10)) {
while (stream.scanDigit(10)) |digit| {
// no overflows here, saturate well before overflow
if (exponent < 0x1000_0000) {
exponent = 10 * exponent + digit;
}
}
return if (negative) -exponent else exponent;
}
return null;
}
Parse the scientific notation component of a float.