From a80c3334a35cc85fe9b4a2ddbbab91d650a0ce3a Mon Sep 17 00:00:00 2001 From: Samuel Lord <9904667+NodeMixaholic@users.noreply.github.com> Date: Sat, 27 Jan 2024 16:23:54 -0600 Subject: [PATCH] Update index.js --- index.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 448e610..9e4e76d 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,5 @@ -function fastInverseSqrt(number) { +//fast inverse sqrt +function fisqrt(number) { const threehalfs = 1.5; const x2 = number * 0.5; let i = new Float32Array(1); @@ -11,3 +12,17 @@ function fastInverseSqrt(number) { y = Math.round(y * 100) / 100; return y; } + +//manual sqrt +function msqrt(number) { + for (var i = 0; i * i <= number; i++) { + if (i * i === number) + return i; + } + return number; +} + +//square +function sq(number) { + return number * number; +}