diff options
Diffstat (limited to 'v_windows/v/vlib/math/q_rsqrt.v')
-rw-r--r-- | v_windows/v/vlib/math/q_rsqrt.v | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/v_windows/v/vlib/math/q_rsqrt.v b/v_windows/v/vlib/math/q_rsqrt.v new file mode 100644 index 0000000..570d3a3 --- /dev/null +++ b/v_windows/v/vlib/math/q_rsqrt.v @@ -0,0 +1,12 @@ +module math + +[inline] +pub fn q_rsqrt(x f64) f64 { + x_half := 0.5 * x + mut i := i64(f64_bits(x)) + i = 0x5fe6eb50c7b537a9 - (i >> 1) + mut j := f64_from_bits(u64(i)) + j *= (1.5 - x_half * j * j) + j *= (1.5 - x_half * j * j) + return j +} |