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!
Create an unsigned 32-bit integer from a literal bit representation.
import fromBinaryStringUint32 from 'https://cdn.jsdelivr.net/gh/stdlib-js/number-uint32-base-from-binary-string@deno/mod.js';
Creates an unsigned 32-bit integer from a literal bit representation.
var bstr = '01010101010101010101010101010101';
var val = fromBinaryStringUint32( bstr );
// returns 1431655765
bstr = '00000000000000000000000000000000';
val = fromBinaryStringUint32( bstr );
// returns 0
bstr = '00000000000000000000000000000010';
val = fromBinaryStringUint32( bstr );
// returns 2
bstr = '11111111111111111111111111111111';
val = fromBinaryStringUint32( bstr );
// returns 4294967295
import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-randu@deno/mod.js';
import round from 'https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-round@deno/mod.js';
import MAX_UINT from 'https://cdn.jsdelivr.net/gh/stdlib-js/constants-uint32-max@deno/mod.js';
import toBinaryStringUint32 from 'https://cdn.jsdelivr.net/gh/stdlib-js/number-uint32-base-to-binary-string@deno/mod.js';
import fromBinaryStringUint32 from 'https://cdn.jsdelivr.net/gh/stdlib-js/number-uint32-base-from-binary-string@deno/mod.js';
var b;
var x;
var y;
var i;
// Convert random integers to literal bit representations and then convert them back...
for ( i = 0; i < 100; i++ ) {
x = round( randu()*MAX_UINT );
b = toBinaryStringUint32( x );
y = fromBinaryStringUint32( b );
console.log( '%d => %s => %d', x, b, y );
}
@stdlib/number-uint16/base/from-binary-string
: create an unsigned 16-bit integer from a literal bit representation.@stdlib/number-uint32/base/to-binary-string
: return a string giving the literal bit representation of an unsigned 32-bit integer.@stdlib/number-uint8/base/from-binary-string
: create an unsigned 8-bit integer from a literal bit representation.
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-2024. The Stdlib Authors.