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!
Convert an integer-valued double-precision floating-point number to a signed 64-bit integer byte array according to host byte order (endianness).
import float64ToInt64Bytes from 'https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@deno/mod.js';
You can also import the following named exports from the package:
import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@deno/mod.js';
Converts an integer-valued double-precision floating-point number to a signed 64-bit integer byte array according to host byte order (endianness).
var out = float64ToInt64Bytes( 4294967297.0 );
// returns <Uint8Array>
Converts an integer-valued double-precision floating-point number to a signed 64-bit integer byte array according to host byte order (endianness) and assigns results to a provided output array.
import Uint8Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@deno/mod.js';
var out = new Uint8Array( 16 );
var y = float64ToInt64Bytes.assign( 4294967297.0, out, 2, 1 );
// returns <Uint8Array>
var bool = ( y === out );
// returns true
- The functions assume that the input value is less than the maximum safe double-precision floating-point integer plus one (i.e.,
2**53
).
import toBinaryStringUint8 from 'https://cdn.jsdelivr.net/gh/stdlib-js/number-uint8-base-to-binary-string@deno/mod.js';
import float64ToInt64Bytes from 'https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@deno/mod.js';
var bytes;
var str;
var sgn;
var x;
var i;
var j;
str = [ '', '', '', '', '', '', '', '', '' ];
x = 1;
for ( i = 0; i < 54; i++ ) {
sgn = ( i&1 ) ? -1 : 1;
bytes = float64ToInt64Bytes( x*sgn );
for ( j = 0; j < bytes.length; j++ ) {
str[ j ] = toBinaryStringUint8( bytes[ j ] );
}
console.log( '%s2**%d => %s', ( sgn < 0 ) ? '-' : '+', i, str.join( ' ' ) );
x *= 2;
}
@stdlib/number-float64/base/to-int32
: convert a double-precision floating-point number to a signed 32-bit integer.
This package is part of stdlib, a standard library 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-2025. The Stdlib Authors.