
Security News
Official Go SDK for MCP in Development, Stable Release Expected in August
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.
double-bits
Advanced tools
Routines for manipulating binary representations of a IEEE 754 double precision numbers.
var db = require("double-bits")
//Get higher order word
console.log(db.hi(1.0).toString(16)) //Prints out: 3ff00000
//Get lower order word
console.log(db.lo(1.0).toString(16)) //Prints out: 0
//Combine two words into a double
console.log(db.pack(0, 0x3ff00000)) //Prints out: 1.0
//More sophisticated example: Print out base 2 representation
var pad = require("pad")
function base2Str(n) {
var f = db.fraction(n)
return (db.sign(n) ? "-" : "") +
"2^" + (db.exponent(n)+1) +
" * 0." + pad(f[1].toString(2), 20, "0") +
pad(f[0].toString(2), 32, "0")
}
console.log(base2Str(1.0))
//Prints out:
//
// 2^1 * 0.10000000000000000000000000000000000000000000000000000
//
npm install double-bits
var db = require("double-bits")
db(n)
Returns a pair of 32-bit unsigned ints encoding the lower/higher order words respectively representing n
n
is an IEEE754 double numberReturns An array, [lo,hi]
encoding n
db.lo(n)
Returns the lower order word of n
n
is an IEEE754 numberReturns The lower order word of n
db.hi(n)
Returns the higher order word of n
n
is an IEEE754 numberReturns The higher order word of n
db.pack(lo, hi)
Given a pair of lower/higher order words, concatenate them into a 64 bit double precision number
lo
is the lower order wordhi
is the higher order wordReturns An IEEE754 double precision number formed by concatenating the bits of lo
and hi
db.sign(n)
Returns the state of the sign bit of n
n
is an IEEE754 double precision numberReturns The sign bit of n
db.exponent(n)
Returns the exponent of n
n
is an IEEE754 double precision numberReturns The exponent of n
db.fraction(n)
Returns the fractional part of n
n
is an IEEE754 double precision numberReturns The fractional part of n
encoded as a pair of numbers, [lo,hi]
where lo
is a 32 bit integer and hi
is a 21 bit integer.
db.denormalized(n)
Test if a double is denormalized.
n
is a numberReturns true
if n
is denormal, false
otherwise
(c) 2014 Mikola Lysenko. BSD License
FAQs
Inspect binary representation of IEEE754 doubles
The npm package double-bits receives a total of 25,567 weekly downloads. As such, double-bits popularity was classified as popular.
We found that double-bits demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.
Security News
New research reveals that LLMs often fake understanding, passing benchmarks but failing to apply concepts or stay internally consistent.
Security News
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.