Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

js-hexfloat

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-hexfloat - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

17

hexfloat.js

@@ -12,13 +12,11 @@ /*

}
var RE_HEXFLOAT =
/([\+\-]?)0x([0-9A-F]+).?([0-9A-F]*)p([\+\-]?[0-9]*)/i;
// 1 2 3 4
var parseHexFloat = function(s) {
// 1 2 3 4 5
var m =
(/^([\+\-]?)0x([0-9A-Z]+).?([0-9A-Z]*)p([\+\-]?)([0-9]*)/i)
.exec(s);
var m = RE_HEXFLOAT.exec(s);
if (!m) return NaN;
var sign = m[1] == '-' ? -1 : 1;
var mantissa = parseInt(m[2] + m[3], 16);
var esign = m[4] == '-' ? -1 : 1;
var exponent = esign * (m[5]|0) - 4*m[3].length;
return sign * mantissa * Math.pow(2, exponent);
var mantissa = parseInt(m[1] + m[2] + m[3], 16);
var exponent = (m[4]|0) - 4*m[3].length;
return mantissa * Math.pow(2, exponent);
};

@@ -45,2 +43,3 @@ var toHexString = function(canonical) {

[ Number, 'parseHexFloat', parseHexFloat],
[ global, 'RE_HEXFLOAT', RE_HEXFLOAT],
[ Number.prototype, 'toHexString', toHexString ]

@@ -47,0 +46,0 @@ ].forEach(function(a){

{
"name": "js-hexfloat",
"version": "0.1.0",
"version": "0.2.0",
"description": "Rudimentary C99 Hexadecimal Float Support in JS",

@@ -5,0 +5,0 @@ "main": "hexfloat.js",

@@ -27,2 +27,10 @@ [![build status](https://secure.travis-ci.org/dankogai/js-hexfloat.png)](http://travis-ci.org/dankogai/js-hexfloat)

### `RE_HEXFLOAT`
`RegExp` object used in `parseHexFloat`:
````javascript
/([\+\-]?)0x([0-9A-F]+).?([0-9A-F]*)p([\+\-]?[0-9]*)/i
````
### `Number.prototype.toHexString(canonical)`

@@ -29,0 +37,0 @@

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