fn isOddInteger(x: f64) bool x: f64183
184
185
186
187
188
189
190
191
192
193
194fn isOddInteger(x: f64) bool {
if (@abs(x) >= 1 << 53) {
// From https://golang.org/src/math/pow.go
// 1 << 53 is the largest exact integer in the float64 format.
// Any number outside this range will be truncated before the decimal point and therefore will always be
// an even integer.
// Without this check and if x overflows i64 the @intFromFloat(r.ipart) conversion below will panic
return false;
}
const r = math.modf(x);
return r.fpart == 0.0 and @as(i64, @intFromFloat(r.ipart)) & 1 == 1;
}