fn frexp_exp32(x: f32, expt: *i32) f32 x: f32expt: *i3225
26
27
28
29
30
31
32
33
34fn frexp_exp32(x: f32, expt: *i32) f32 {
const k = 235; // reduction constant
const kln2 = 162.88958740; // k * ln2
const exp_x = @exp(x - kln2);
const hx = @as(u32, @bitCast(exp_x));
// TODO zig should allow this cast implicitly because it should know the value is in range
expt.* = @as(i32, @intCast(hx >> 23)) - (0x7f + 127) + k;
return @as(f32, @bitCast((hx & 0x7fffff) | ((0x7f + 127) << 23)));
}