Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "number/float64/base/set-low-word/docs/types/index.d"

Index

Functions

Functions

Export assignment setLowWord

  • setLowWord(x: number, low: number): number
  • Sets the less significant 32 bits of a double-precision floating-point number.

    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 can we find the lower order bits? If little endian, the first; if big endian, the second.

    References

    Parameters

    • x: number

      double

    • low: number

      unsigned 32-bit integer to replace the lower order word of x

    Returns number

    double having the same higher order word as x

    Example

    var low = 5 >>> 0; // => 00000000000000000000000000000101
    
    var x = 3.14e201; // => 0 11010011100 01001000001011000011 10010011110010110101100010000010
    
    var y = setLowWord( x, low ); // => 0 11010011100 01001000001011000011 00000000000000000000000000000101
    // returns 3.139998651394392e+201

    Example

    var PINF = require( `@stdlib/constants/float64/pinf` );
    var NINF = require( `@stdlib/constants/float64/ninf` );
    
    var low = 12345678;
    
    var y = setLowWord( PINF, low );
    // returns NaN
    
    y = setLowWord( NINF, low );
    // returns NaN
    
    y = setLowWord( NaN, low );
    // returns NaN