Options
All
  • Public
  • Public/Protected
  • All
Menu

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

Index

Functions

Functions

Export assignment setHighWord

  • setHighWord(x: number, high: number): number
  • Sets the more 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 higher order bits? If little endian, the second; if big endian, the first.

    References

    Parameters

    • x: number

      double

    • high: number

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

    Returns number

    double having the same lower order word as x

    Example

    var high = 5 >>> 0; // => 0 00000000000 00000000000000000101
    
    var y = setHighWord( 3.14e201, high ); //  => 0 00000000000 0000000000000000010110010011110010110101100010000010
    // returns 1.18350528745e-313

    Example

    var PINF = require( `@stdlib/constants/float64/pinf` ); // => 0 11111111111 00000000000000000000 00000000000000000000000000000000
    
    var high = 1072693248 >>> 0; // => 0 01111111111 00000000000000000000
    
    // Set the higher order bits of `+infinity` to return `1`:
    var y = setHighWord( PINF, high ); // => 0 01111111111 0000000000000000000000000000000000000000000000000000
    // returns 1.0