// convert to desired denomination
if (UNITS[outputUnit] !== 0) {
- f = i.slice(-UNITS[outputUnit]) + f
+ f = i.padStart(40, '0').slice(-UNITS[outputUnit]) + f
i = i.slice(0, -UNITS[outputUnit])
}
i = i.replace(/^0*/g, '') ?? '0'
assert.equal(result, '1')\r
})\r
\r
+ it('should convert 1 raw to 10^-29 nano', async () => {\r
+ const result = await Tools.convert('1', 'RAW', 'NANO')\r
+ assert.equal(result, '.000000000000000000000000000001')\r
+ })\r
+\r
it('should ignore leading and trailing zeros', async () => {\r
const result = await Tools.convert('0011002200.0033004400', 'nano', 'nano')\r
assert.equal(result, '11002200.00330044')\r