Update index.js

This commit is contained in:
Samuel Lord 2024-01-27 16:23:54 -06:00 committed by GitHub
parent 5744fa3c22
commit a80c3334a3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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;
}