1.0.2 • Published 5 years ago

fast-inv-sqrt v1.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

Fast Inverse Square Root for JS & TS

Implements the infamous Fast Inverse Square Root function of Quake fame.

This library exports a single invSqrt(x) function that calculates (estimates) 1/Math.sqrt(x), but with a 5x performance improvement.

Installation

Just npm add or yarn add the module fast-inv-sqrt.

Usage

import { invSqrt } from "fast-inv-sqrt";

console.log(invSqrt(256));       // 0.06239419684904888
console.log(1 / Math.sqrt(256)); // 0.0625