What is @stdlib/constants-float64-high-word-sign-mask?
@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.
What are @stdlib/constants-float64-high-word-sign-mask's main functionalities?
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
Other packages similar to @stdlib/constants-float64-high-word-sign-mask
math-float64-signbit
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.
bit-twiddle
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.
About stdlib...
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!
FLOAT64_HIGH_WORD_SIGN_MASK
High word mask for the sign bit of a double-precision floating-point number.
Installation
npm install @stdlib/constants-float64-high-word-sign-mask
Usage
var FLOAT64_HIGH_WORD_SIGN_MASK = require( '@stdlib/constants-float64-high-word-sign-mask' );
FLOAT64_HIGH_WORD_SIGN_MASK
High word mask for the sign bit of a double-precision floating-point number.
var bool = ( FLOAT64_HIGH_WORD_SIGN_MASK === 0x80000000 );
Examples
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 );
var out = (hi & FLOAT64_HIGH_WORD_SIGN_MASK)>>>0;
out = hi & (~FLOAT64_HIGH_WORD_SIGN_MASK);
out = fromWords( out, getLowWord( x ) );
C APIs
Usage
#include "stdlib/constants/float64/high_word_sign_mask.h"
STDLIB_CONSTANT_FLOAT64_HIGH_WORD_SIGN_MASK
Macro for the high word mask for the sign bit of a double-precision floating-point number.
Notice
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.
License
See LICENSE.
Copyright
Copyright © 2016-2024. The Stdlib Authors.
0.2.1 (2024-07-27)
No changes reported for this release.
</section>
<!-- /.release -->
<section class="release" id="v0.2.0">