Launch Week Day 5: Introducing Reachability for PHP.Learn More
Socket
Book a DemoSign in
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.4.4
to
0.4.5
+12
-3
hexfloat.js
/*
* $Id: hexfloat.js,v 0.4 2016/01/05 07:13:22 dankogai Exp dankogai $
*
* Licensed under the MIT license.

@@ -21,3 +19,7 @@ * http://www.opensource.org/licenses/mit-license.php

: arguments;
if (!m) return NaN;
if (!m) {
var mx = (/^([\+\-]?)inf(?:inity)?/i).exec(arguments[0]);
if (!mx) return NaN;
return mx[1] == '-' ? -1/0 : 1/0;
}
var mantissa = parseInt(m[1] + m[2] + m[3], 16);

@@ -28,2 +30,9 @@ var exponent = (m[4]|0) - 4*m[3].length;

var toHexString = function() {
if (this == 0.0) {
return (1/0 !== 1/this ? '-' : '') + '0x0p+0';
} else if (isNaN(this)) {
return 'nan';
}else if (!isFinite(this)) {
return (this < 0 ? '-' : '') + 'inf';
}
var sign = this < 0 ? '-' : '';

@@ -30,0 +39,0 @@ var a = Math.abs(this);

+1
-1
{
"name": "js-hexfloat",
"version": "0.4.4",
"version": "0.4.5",
"description": "Rudimentary C99 Hexadecimal Floating Point Support in JS",

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

/*
* $Id: 00-basic.js,v 0.4 2016/01/08 03:58:34 dankogai Exp dankogai $
*
* use mocha to test me

@@ -21,3 +19,3 @@ * http://visionmedia.github.com/mocha/

describe('Hexadecimal Float', function () {
describe('Basic', function () {
it('Math.PI == 0x1.921fb54442d18p+1',

@@ -45,4 +43,2 @@ is(parseHexFloat('0x1.921fb54442d18p+1'), Math.PI));

is(parseHexFloat('-0x1p-42'), -Math.pow(2, -42)));
it('isNaN(parseHexFloat("nonsense"))',
is(isNaN(parseHexFloat('nonsense')), true));
it('0x1p-1074 == Number.MIN_VALUE',

@@ -59,1 +55,23 @@ is(parseHexFloat('0x1p-1074'), Number.MIN_VALUE));

});
describe('Extreme', function () {
it('parseHexFloat("+0x0p+0") == ' + 0.0,
is(parseHexFloat('+0x0p+0'), 0.0));
it('(0.0).toHexString() == "0x0p+0"',
is((0.0).toHexString(), '0x0p+0'));
it('parseHexFloat("-0x0p+0") == ' + 0.0,
is(parseHexFloat('-0x0p+0'), -1.0*0.0));
it('(-1.0*0.0).toHexString() == "-0x0p+0"',
is((-1.0*0.0).toHexString(), '-0x0p+0'));
it('parseHexFloat("inf") == ' + 1/0,
is(parseHexFloat('inf'), 1/0));
it('(1/0).toHexString() == "inf"',
is((-1/0).toHexString(), '-inf'));
it('parseHexFloat("-inf") == ' + -1/0,
is(parseHexFloat('-inf'), -1/0));
it('(-1/0).toHexString() == "-inf"',
is((-1/0).toHexString(), '-inf'));
it('parseHexFloat("uninfected") == ' + NaN,
is(isNaN(parseHexFloat('uninfected')), true));
it('(0/0).toHexString() == "nan"',
is((0/0).toHexString(), 'nan'));
});
/*
* $Id: 01-roundtrip.js,v 0.2 2016/01/08 04:03:25 dankogai Exp dankogai $
*
* use mocha to test me

@@ -5,0 +3,0 @@ * http://visionmedia.github.com/mocha/

@@ -28,5 +28,4 @@ <html>

<body>
$Id: index.html,v 0.1 2016/01/04 11:51:29 dankogai Exp dankogai $
<div id="mocha"></div>
</body>
</html>

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet