biggystring
Advanced tools
Comparing version 4.1.1 to 4.1.2
@@ -309,3 +309,3 @@ "use strict"; | ||
function precisionAdjust(type, x1, precision = 0) { | ||
var _a; | ||
var _a, _b; | ||
validate(x1); | ||
@@ -341,3 +341,7 @@ let negative = false; | ||
const addValue = '1' + zeroString; | ||
outCombined = add(outCombined, addValue); | ||
// Leading zeros get removed after an `add`. Save the number of leading zeros | ||
// and add them back | ||
const leadingZeros = ((_b = outCombined.match(/^0+/)) !== null && _b !== void 0 ? _b : [''])[0].length; | ||
const leadingZerosString = new Array(leadingZeros).join('0'); | ||
outCombined = leadingZerosString + add(outCombined, addValue); | ||
} | ||
@@ -344,0 +348,0 @@ const newDecimalPos = decimalPos + (outCombined.length - combined.length); |
@@ -438,2 +438,11 @@ "use strict"; | ||
}); | ||
it('-0.006234 -5 => -0.00623', () => { | ||
chai_1.assert.equal(index_1.round('-0.006234', -5), '-0.00623'); | ||
}); | ||
it('-0.006237 -5 => -0.00624', () => { | ||
chai_1.assert.equal(index_1.round('-0.006237', -5), '-0.00624'); | ||
}); | ||
it('0.006237 -5 => 0.00624', () => { | ||
chai_1.assert.equal(index_1.round('0.006237', -5), '0.00624'); | ||
}); | ||
it('-0.1234 0 => 0', () => { | ||
@@ -493,4 +502,10 @@ chai_1.assert.equal(index_1.round('-0.1234', 0), '0'); | ||
}); | ||
it('0.000058196685058537 -8 => 0.0000582', () => { | ||
chai_1.assert.equal(index_1.round('0.000058196685058537', -8), '0.0000582'); | ||
}); | ||
}); | ||
describe('ceil', () => { | ||
it('-0.006237 -5 => -0.00624', () => { | ||
chai_1.assert.equal(index_1.ceil('-0.006237', -5), '-0.00624'); | ||
}); | ||
it('-12345.678 8 => -100000000', () => { | ||
@@ -534,2 +549,5 @@ chai_1.assert.equal(index_1.ceil('-12345.678', 8), '-100000000'); | ||
describe('floor', () => { | ||
it('-0.006237 -5 => -0.00623', () => { | ||
chai_1.assert.equal(index_1.floor('-0.006237', -5), '-0.00623'); | ||
}); | ||
it('-12345.678 8 => 0', () => { | ||
@@ -536,0 +554,0 @@ chai_1.assert.equal(index_1.floor('-12345.678', 8), '0'); |
{ | ||
"name": "biggystring", | ||
"version": "4.1.1", | ||
"version": "4.1.2", | ||
"description": "Full floating point big number library using regular Javascript string", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
114539
14
1462