biggystring
Advanced tools
Comparing version
@@ -137,11 +137,14 @@ /** | ||
} | ||
const pos = x.indexOf('.'); | ||
if (pos === -1) { | ||
throw new Error('Invalid fixed point number'); | ||
let pos = x.indexOf('.'); | ||
if (pos !== -1) { | ||
// Make sure there is only one '.' | ||
let x2 = x.substr(0, pos) + x.substr(pos + 1); | ||
const lastPos = x2.indexOf('.'); | ||
if (lastPos !== -1) { | ||
throw new Error('Invalid fixed point number. Contains more than one decimal point'); | ||
} | ||
} else { | ||
pos = x.length - 1; | ||
} | ||
// Make sure there is only one '.' | ||
const lastPos = x.indexOf('.'); | ||
if (lastPos !== pos) { | ||
throw new Error('Invalid fixed point number. Contains more than one decimal point'); | ||
} | ||
const addZeros = multiplier - (x.length - pos - 1); | ||
@@ -148,0 +151,0 @@ if (addZeros < 0) { |
@@ -141,11 +141,14 @@ 'use strict'; | ||
} | ||
const pos = x.indexOf('.'); | ||
if (pos === -1) { | ||
throw new Error('Invalid fixed point number'); | ||
let pos = x.indexOf('.'); | ||
if (pos !== -1) { | ||
// Make sure there is only one '.' | ||
let x2 = x.substr(0, pos) + x.substr(pos + 1); | ||
const lastPos = x2.indexOf('.'); | ||
if (lastPos !== -1) { | ||
throw new Error('Invalid fixed point number. Contains more than one decimal point'); | ||
} | ||
} else { | ||
pos = x.length - 1; | ||
} | ||
// Make sure there is only one '.' | ||
const lastPos = x.indexOf('.'); | ||
if (lastPos !== pos) { | ||
throw new Error('Invalid fixed point number. Contains more than one decimal point'); | ||
} | ||
const addZeros = multiplier - (x.length - pos - 1); | ||
@@ -152,0 +155,0 @@ if (addZeros < 0) { |
{ | ||
"name": "biggystring", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "Wrapper for bn.js to directly operate on strings as big numbers", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
37047
1.04%363
1.11%0
-100%