We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bn
latest
not relevant
No response
when you call format({ units: 0, precision: 0 }) it will not return the correct value
format({ units: 0, precision: 0 })
the same happens on parseUnits function
parseUnits
the workaround we've been doing on FE side is: bn(amount).mul(10).format({ units: 1, precision: 0 });
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
units: 0
this is very overwhelming to do as we have many projects and some places can be forgotten, leading to number bugs.
### Contract ABI _No response_ ### Errors _No response_
The text was updated successfully, but these errors were encountered:
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.
Sorry, something went wrong.
maschad
Successfully merging a pull request may close this issue.
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.
The text was updated successfully, but these errors were encountered: