Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "number/float64/base/from-words/docs/types/index.d"

Index

Functions

Functions

Export assignment fromWords

  • fromWords(high: number, low: number): number
  • Creates a double-precision floating-point number from a higher order word (unsigned 32-bit integer) and a lower order word (unsigned 32-bit integer).

    Notes

    float64 (64 bits)
    f := fraction (significand/mantissa) (52 bits)
    e := exponent (11 bits)
    s := sign bit (1 bit)
    
    |-------- -------- -------- -------- -------- -------- -------- --------|
    |                                Float64                                |
    |-------- -------- -------- -------- -------- -------- -------- --------|
    |              Uint32               |               Uint32              |
    |-------- -------- -------- -------- -------- -------- -------- --------|

    If little endian (more significant bits last):

                            <-- lower      higher -->
    |   f7       f6       f5       f4       f3       f2    e2 | f1 |s|  e1  |

    If big endian (more significant bits first):

                            <-- higher      lower -->
    |s| e1    e2 | f1     f2       f3       f4       f5        f6      f7   |

    In which Uint32 should we place the higher order bits? If little endian, the second; if big endian, the first.

    References

    Parameters

    • high: number

      higher order word (unsigned 32-bit integer)

    • low: number

      lower order word (unsigned 32-bit integer)

    Returns number

    floating-point number

    Example

    var v = fromWords( 1774486211, 2479577218 );
    // returns 3.14e201

    Example

    var v = fromWords( 3221823995, 1413754136 );
    // returns -3.141592653589793

    Example

    var v = fromWords( 0, 0 );
    // returns 0.0

    Example

    var v = fromWords( 2147483648, 0 );
    // returns -0.0

    Example

    var v = fromWords( 2146959360, 0 );
    // returns NaN

    Example

    var v = fromWords( 2146435072, 0 );
    // returns Infinity

    Example

    var v = fromWords( 4293918720, 0 );
    // returns -Infinity