Class: DoubleBits

jsts.index.DoubleBits

new DoubleBits()

DoubleBits manipulates Double numbers by using bit manipulation and bit-field extraction. For some operations (such as determining the exponent) this is more accurate than using mathematical operations (which suffer from round-off error).

The algorithms and constants in this class apply only to IEEE-754 double-precision floating point format. NOTE: Since the only numberformat in JavaScript is IEEE-754 the code in DoubleBits could not be easily ported. Instead, using algorithms found here: http://www.merlyn.demon.co.uk/js-exact.htm

Source:

Methods

(static) CVTFWD(NumW, Qty) → {Number}

Calculates the exponent of the bit-pattern for a number. Uses code from: http://www.merlyn.demon.co.uk/js-exact.htm
Parameters:
Name Type Description
NumW Number 32 or 64 to denote the number of bits.
Qty Number the number to calculate the bit pattern for.
Source:
Returns:
The integer value of the exponent.
Type
Number

(static) exponent(d) → {Number}

Calculates the exponent-part of the bit-pattern for a number
Parameters:
Name Type Description
d Number the IEEE-754-value to calculate the exponent for.
Source:
Returns:
the exponent part of the bit-mask.
Type
Number

(static) powerOf2(exp) → {Number}

Calculates the power of two for a number
Parameters:
Name Type Description
exp Number value to pow.
Source:
Returns:
the pow'ed value.
Type
Number