native.js (1721B)
1 /** 2 * @license Apache-2.0 3 * 4 * Copyright (c) 2020 The Stdlib Authors. 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 'use strict'; 20 21 // MODULES // 22 23 var addon = require( './../src/addon.node' ); 24 25 26 // MAIN // 27 28 /** 29 * Sets the less significant 32 bits of a double-precision floating-point number. 30 * 31 * @private 32 * @param {number} x - double 33 * @param {uinteger32} low - unsigned 32-bit integer to replace the lower order word of `x` 34 * @returns {number} double having the same higher order word as `x` 35 * 36 * @example 37 * var low = 5 >>> 0; // => 00000000000000000000000000000101 38 * 39 * var x = 3.14e201; // => 0 11010011100 01001000001011000011 10010011110010110101100010000010 40 * 41 * var y = setLowWord( x, low ); // => 0 11010011100 01001000001011000011 00000000000000000000000000000101 42 * // returns 3.139998651394392e+201 43 * 44 * @example 45 * var PINF = require( '@stdlib/constants/float64/pinf' ); 46 * var NINF = require( '@stdlib/constants/float64/ninf' ); 47 * 48 * var low = 12345678; 49 * 50 * var y = setLowWord( PINF, low ); 51 * // returns NaN 52 * 53 * y = setLowWord( NINF, low ); 54 * // returns NaN 55 * 56 * y = setLowWord( NaN, low ); 57 * // returns NaN 58 */ 59 function setLowWord( x, low ) { 60 return addon( x, low ); 61 } 62 63 64 // EXPORTS // 65 66 module.exports = setLowWord;