Closed LuizAsFight closed 1 month ago
Thanks for opening this @LuizAsFight just so that we are on the same page, could you share a few examples of expected results. Such as:
expect(bn('1000000000').format({ units: 0, precision: 0 })).toEqual('1,000,000,000');
expect(bn('1000000000').format({ units: 0, precision: 2 })).toEqual('1,000,000,000.00');
bn('1000000000').format({
minPrecision: 2,
})
).toEqual('1,000,000,000.00');
bn('1000000000').format({
minPrecision: 2,
units: 8,
})
).toEqual('10.00');
This will just help us to have a clear consensus around the desired output.
fuels-ts SDK Version
latest
Toolchain Versions
not relevant
Node.js Version
No response
Browser
No response
Operating System
No response
Describe the Problem
when you call
format({ units: 0, precision: 0 })
it will not return the correct valuethe same happens on
parseUnits
functionCode Snippet
which is basically multiplying by 10 first, then converting to units 1, which at the end of the day will be the same of passing
units: 0
this is very overwhelming to do as we have many projects and some places can be forgotten, leading to number bugs.