bigint-isqrt

0.3.2 • Public • Published

bigint-isqrt

======================

NPM

A function that returns the square root (or it's floor-ed value if the root is not an integer) of a BigInt number.

======================

example:

var sqrt = require('bigint-isqrt');

var r1 = BigInt('25');
console.log("Square root of 25 = ",sqrt(r1));//Square root of 25 = 5

r1 = BigInt('82120471531550314555681345949499512621827274120673745141541602816614526075010755373654280259022317599142038423759320355177481886719814621305828811322920076213800348341464996337890625');
console.log(sqrt(r1));//9062034624274524065844376014975805577107171799890766992670739972241112960081909332275390625n

//No error with negative numbers
//You should take care of `BigInt` to be not negative number.
//No built-in checks for this are implemented.
//This function had been made as the fastest way to count square root

r1 = BigInt('-25');
console.log(sqrt(r1));//-25n

Dependencies (0)

    Dev Dependencies (2)

    Package Sidebar

    Install

    npm i bigint-isqrt

    Weekly Downloads

    296

    Version

    0.3.2

    License

    LGPL-3.0

    Unpacked Size

    14.7 kB

    Total Files

    6

    Last publish

    Collaborators

    • nickkolok
    • aisse-258