From 24fb7c44eafadf13b05f2cc13ea171adc128e625 Mon Sep 17 00:00:00 2001 From: Samuel Lord <9904667+NodeMixaholic@users.noreply.github.com> Date: Sat, 27 Jan 2024 13:49:39 -0600 Subject: [PATCH] Update index.js --- index.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index 4535423..d651031 100644 --- a/index.js +++ b/index.js @@ -1,8 +1,10 @@ -//wow. -function fastInvSqrt(x) { - var xhalf = 0.5 * x; - var i = x; - i = i * (1.5 - xhalf * i * i); - i = i * (1.5 - xhalf * i * i); - return i; +//now even more amazing! +function fastInverseSqrt(number) { + const threehalfs = 1.5; + const x2 = number * 0.5; + let i = new Float32Array(1); + i[0] = number; + let y = new Int32Array(i.buffer); + y = threehalfs - (x2 * y * y); + return y; }