Manipulate the integer parts of a JS Number, including frexp and ldexp.
npm install intparts#intparts
Manipulate the integer parts of a JS Number, including frexp and ldexp.
##Author(s)
Christoph Zurnieden
##Installation
``shell`
$ git clone https://github.com/czurnieden/intparts.git
$ cd intparts
$ npm install -g./bin
There is also a Unix (or newer Macs) dependent CLI version in .
Please be aware that this module assumes little endian.
##Version
0.0.1 Initial publication
##Description
This library implements some of the functions to inspect the innards of a 64 bit double, the default type in ECMAScript up to version 5.1 at least. It allows direct manipulation of the bits in a Number. Included are ports of C-lib's frexp and ldexp.
This module runs as ams.js where applicable.
##Usage
The usage is like with any other node/browser module:
`javascript``
var ip = require('intparts');
var raw_exponent = ip.getexponent(123.312); // 0x405
var unbiased_exponent = ip.frexp(123.321)[1]; // 7
This program offers ten functions which are in alphabetical order:
frexp(number) Uint32Array containing the mantissa and the exponent in that order such that mantissa * 2^exponent = number getexponent(number) gethigh(number) getlow(number) getsign(number) getwords(number) ldexp(mantissa,exponent) mantissa * 2^exponent = numbersethigh(integer,number) numberReturn: the manipulated number
setlow(integer,number) numberReturn: the manipulated number
setwords(number,high_integer,low_integer) numberReturn: the manipulated number
This module does no error catching.
##Example
No example yet, but ideas are welcome.