Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
@stdlib/constants-float64-high-word-sign-mask
Advanced tools
High word mask for the sign bit of a double-precision floating-point number.
@stdlib/constants-float64-high-word-sign-mask is a package that provides the high word mask for the sign bit of a double-precision floating-point number (float64). This mask can be used to isolate or manipulate the sign bit of a float64 number.
Isolate the sign bit
This feature allows you to isolate the sign bit of a float64 number by using the SIGN_MASK constant. The example demonstrates how to extract the sign bit from a given high word.
const SIGN_MASK = require('@stdlib/constants-float64-high-word-sign-mask');
const highWord = 0x80000000; // Example high word with sign bit set
const signBit = highWord & SIGN_MASK;
console.log(signBit); // Output: 2147483648
Check if a number is negative
This feature allows you to check if a float64 number is negative by examining its sign bit. The example shows how to determine if a number is negative using the SIGN_MASK constant.
const SIGN_MASK = require('@stdlib/constants-float64-high-word-sign-mask');
const highWord = 0x80000000; // Example high word with sign bit set
const isNegative = (highWord & SIGN_MASK) !== 0;
console.log(isNegative); // Output: true
The math-float64-signbit package provides a function to determine the sign bit of a double-precision floating-point number. Unlike @stdlib/constants-float64-high-word-sign-mask, which provides a constant for bitwise operations, math-float64-signbit offers a higher-level function to directly check the sign bit.
The bit-twiddle package offers a variety of bitwise operations, including functions to manipulate and inspect the bits of numbers. While it is more general-purpose compared to @stdlib/constants-float64-high-word-sign-mask, it can be used to achieve similar results through more complex operations.
We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.
The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.
When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.
To join us in bringing numerical computing to the web, get started by checking us out on GitHub, and please consider financially supporting stdlib. We greatly appreciate your continued support!
High word mask for the sign bit of a double-precision floating-point number.
npm install @stdlib/constants-float64-high-word-sign-mask
var FLOAT64_HIGH_WORD_SIGN_MASK = require( '@stdlib/constants-float64-high-word-sign-mask' );
High word mask for the sign bit of a double-precision floating-point number.
// 0x80000000 = 2147483648 => 1 00000000000 00000000000000000000
var bool = ( FLOAT64_HIGH_WORD_SIGN_MASK === 0x80000000 );
// returns true
var getHighWord = require( '@stdlib/number-float64-base-get-high-word' );
var getLowWord = require( '@stdlib/number-float64-base-get-low-word' );
var fromWords = require( '@stdlib/number-float64-base-from-words' );
var FLOAT64_HIGH_WORD_SIGN_MASK = require( '@stdlib/constants-float64-high-word-sign-mask' );
var x = -11.5;
var hi = getHighWord( x ); // 1 10000000010 01110000000000000000
// returns 3223781376
// Mask off all bits except for the sign bit:
var out = (hi & FLOAT64_HIGH_WORD_SIGN_MASK)>>>0; // 1 00000000000 00000000000000000000
// returns 2147483648
// Turn off the sign bit and leave other bits unchanged:
out = hi & (~FLOAT64_HIGH_WORD_SIGN_MASK); // 0 10000000010 01110000000000000000
// returns 1076297728
// Generate a new value:
out = fromWords( out, getLowWord( x ) );
// returns 11.5
#include "stdlib/constants/float64/high_word_sign_mask.h"
Macro for the high word mask for the sign bit of a double-precision floating-point number.
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
See LICENSE.
Copyright © 2016-2024. The Stdlib Authors.
FAQs
High word mask for the sign bit of a double-precision floating-point number.
We found that @stdlib/constants-float64-high-word-sign-mask demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.