New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ieee754-buffer

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ieee754-buffer - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

3

CHANGELOG.md
# CHANGELOG
## 1.0.1 - 2019-12-31
- Fix: rounding byte values must work the same on all browsers
## 1.0.0 - 2019-12-30

@@ -4,0 +7,0 @@ - New package structure:

8

dist/ieee754-buffer.js

@@ -1,4 +0,4 @@

(function(h,g){"object"===typeof exports&&"undefined"!==typeof module?g(exports):"function"===typeof define&&define.amd?define(["exports"],g):(h=h||self,g(h.IEEE754Buffer={}))})(this,function(h){var g=function(f,a){this.ebits=f;this.fbits=a;this.bias=(1<<f-1)-1;this.numBytes=Math.ceil((f+a)/8);this.biasP2=Math.pow(2,this.bias+1);this.ebitsFbits=f+a;this.fbias=Math.pow(2,-(8*this.numBytes-1-f))};g.prototype.pack=function(f,a,e){Math.abs(a)>this.biasP2-2*this.ebitsFbits&&(a=0>a?-Infinity:Infinity);
var d=0>((a=+a)||1/a)?1:0>a?1:0;a=Math.abs(a);var c=Math.min(Math.floor(Math.log(a)/Math.LN2),1023),b=Math.round(a/Math.pow(2,c)*Math.pow(2,this.fbits));a!==a?(b=Math.pow(2,this.fbits-1),c=(1<<this.ebits)-1):0!==a&&(a>=Math.pow(2,1-this.bias)?(2<=b/Math.pow(2,this.fbits)&&(c+=1,b=1),c>this.bias?(c=(1<<this.ebits)-1,b=0):(c+=this.bias,b=Math.round(b)-Math.pow(2,this.fbits))):(b=Math.round(a/Math.pow(2,1-this.bias-this.fbits)),c=0));return this.packFloatBits_(f,e,d,c,b)};g.prototype.unpack=function(f,
a){for(var e=(1<<this.ebits)-1,d="",c=this.numBytes-1;0<=c;c--){var b=f[c+a].toString(2);d+="00000000".substring(b.length)+b}c="1"==d.charAt(0)?-1:1;d=d.substring(1);b=parseInt(d.substring(0,this.ebits),2);d=d.substring(this.ebits);if(b==e)return 0!==parseInt(d,2)?NaN:Infinity*c;0===b?(b+=1,e=parseInt(d,2)):e=parseInt("1"+d,2);return c*e*this.fbias*Math.pow(2,b-this.bias)};g.prototype.packFloatBits_=function(f,a,e,d,c){var b=[];b.push(e);for(e=this.ebits;0<e;--e)b[e]=d%2?1:0,d=Math.floor(d/2);d=b.length;
for(e=this.fbits;0<e;--e)b[d+e]=c%2?1:0,c=Math.floor(c/2);c=b.join("");b=this.numBytes+a-1;for(d=a;b>=a;)f[b]=parseInt(c.substring(0,8),2),c=c.substring(8),b--,d++;return d};h.IEEE754Buffer=g;Object.defineProperty(h,"__esModule",{value:!0})});
(function(h,g){"object"===typeof exports&&"undefined"!==typeof module?g(exports):"function"===typeof define&&define.amd?define(["exports"],g):(h=h||self,g(h.IEEE754Buffer={}))})(this,function(h){function g(e){var a=Math.floor(e);e-=a;return.5>e?a:.5<e?a+1:a%2?a+1:a}var k=function(e,a){this.ebits=e;this.fbits=a;this.bias=(1<<e-1)-1;this.numBytes=Math.ceil((e+a)/8);this.biasP2=Math.pow(2,this.bias+1);this.ebitsFbits=e+a;this.fbias=Math.pow(2,-(8*this.numBytes-1-e))};k.prototype.pack=function(e,a,f){Math.abs(a)>
this.biasP2-2*this.ebitsFbits&&(a=0>a?-Infinity:Infinity);var d=0>((a=+a)||1/a)?1:0>a?1:0;a=Math.abs(a);var c=Math.min(Math.floor(Math.log(a)/Math.LN2),1023),b=g(a/Math.pow(2,c)*Math.pow(2,this.fbits));a!==a?(b=Math.pow(2,this.fbits-1),c=(1<<this.ebits)-1):0!==a&&(a>=Math.pow(2,1-this.bias)?(2<=b/Math.pow(2,this.fbits)&&(c+=1,b=1),c>this.bias?(c=(1<<this.ebits)-1,b=0):(c+=this.bias,b=g(b)-Math.pow(2,this.fbits))):(b=g(a/Math.pow(2,1-this.bias-this.fbits)),c=0));return this.packFloatBits_(e,f,d,c,
b)};k.prototype.unpack=function(e,a){for(var f=(1<<this.ebits)-1,d="",c=this.numBytes-1;0<=c;c--){var b=e[c+a].toString(2);d+="00000000".substring(b.length)+b}c="1"==d.charAt(0)?-1:1;d=d.substring(1);b=parseInt(d.substring(0,this.ebits),2);d=d.substring(this.ebits);if(b==f)return 0!==parseInt(d,2)?NaN:Infinity*c;0===b?(b+=1,f=parseInt(d,2)):f=parseInt("1"+d,2);return c*f*this.fbias*Math.pow(2,b-this.bias)};k.prototype.packFloatBits_=function(e,a,f,d,c){var b=[];b.push(f);for(f=this.ebits;0<f;--f)b[f]=
d%2?1:0,d=Math.floor(d/2);d=b.length;for(f=this.fbits;0<f;--f)b[d+f]=c%2?1:0,c=Math.floor(c/2);c=b.join("");b=this.numBytes+a-1;for(d=a;b>=a;)e[b]=parseInt(c.substring(0,8),2),c=c.substring(8),b--,d++;return d};h.IEEE754Buffer=k;Object.defineProperty(h,"__esModule",{value:!0})});

@@ -108,3 +108,3 @@ /*

/** @type {number} */
let fraction = Math.round(num / Math.pow(2, exp) * Math.pow(2, this.fbits));
let fraction = roundToEven(num / Math.pow(2, exp) * Math.pow(2, this.fbits));
// NaN

@@ -127,6 +127,6 @@ if (num !== num) {

exp = exp + this.bias;
fraction = Math.round(fraction) - Math.pow(2, this.fbits);
fraction = roundToEven(fraction) - Math.pow(2, this.fbits);
}
} else {
fraction = Math.round(num / Math.pow(2, 1 - this.bias - this.fbits));
fraction = roundToEven(num / Math.pow(2, 1 - this.bias - this.fbits));
exp = 0;

@@ -221,1 +221,20 @@ }

}
/**
* Round a number to its nearest even value.
* @param {number} n The number.
* @return {number}
* @private
*/
function roundToEven(n) {
/** @type {number} */
let w = Math.floor(n);
let f = n - w;
if (f < 0.5) {
return w;
}
if (f > 0.5) {
return w + 1;
}
return w % 2 ? w + 1 : w;
}
{
"name": "ieee754-buffer",
"version": "1.0.0",
"version": "1.0.1",
"description": "A module to encode and decode IEEE 754 floating point numbers.",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/rochars/ieee754-buffer",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc