Update index.js

This commit is contained in:
Samuel Lord 2024-01-27 13:49:39 -06:00 committed by GitHub
parent 7409488119
commit 24fb7c44ea
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

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