Skip to content

beaulac/node-intexp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

intexp: frexp for integers

Similarly to the libc frexp function, this decomposes a given integer value x into an integer coefficient c and an integral power of two n such that c * 2n = x

ldexp is also provided as an inverse function for convenience.

Methods

intexp(integer)

Returns [coefficient, exponent] e.g.

const {intexp} = require('intexp');

const decomposed = intexp(4864) // [19, 8]

ldexp(coefficient, exponent)

Returns integer given coefficient and exponent. e.g.

const {ldexp} = require('intexp');

const int = ldexp(19, 8) // 4864

About

frexp for integers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published