aboutsummaryrefslogtreecommitdiff
path: root/v_windows/v/vlib/math/q_rsqrt.v
diff options
context:
space:
mode:
authorIndrajith K L2022-12-03 17:00:20 +0530
committerIndrajith K L2022-12-03 17:00:20 +0530
commitf5c4671bfbad96bf346bd7e9a21fc4317b4959df (patch)
tree2764fc62da58f2ba8da7ed341643fc359873142f /v_windows/v/vlib/math/q_rsqrt.v
downloadcli-tools-windows-f5c4671bfbad96bf346bd7e9a21fc4317b4959df.tar.gz
cli-tools-windows-f5c4671bfbad96bf346bd7e9a21fc4317b4959df.tar.bz2
cli-tools-windows-f5c4671bfbad96bf346bd7e9a21fc4317b4959df.zip
Adds most of the toolsHEADmaster
Diffstat (limited to 'v_windows/v/vlib/math/q_rsqrt.v')
-rw-r--r--v_windows/v/vlib/math/q_rsqrt.v12
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
+}