Skip to content
New issue

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

u128 division not working for some big number #362

Open
hdriqi opened this issue Jan 6, 2021 · 1 comment
Open

u128 division not working for some big number #362

hdriqi opened this issue Jan 6, 2021 · 1 comment
Labels
bug Something isn't working T-dev-tools

Comments

@hdriqi
Copy link

hdriqi commented Jan 6, 2021

Describe the bug
u128 division not working as expected for number bigger than 300 N (300 * 10^24).
Used to calculate commission/royalty fee.

To Reproduce
Steps to reproduce the behavior:

const mul = u128.mul(
u128.from('5000000000000000000000000000'),
u128.from(95)
)
log(mul.toString()) // true return 475000000000000000000000000000

const div100 = u128.div(mul, u128.from(100))
log(div100.toString()) // false return 0

const _div10 = u128.div10(mul)
const _div100 = u128.div10(_div10)
log(_div100.toString()) // true return 4750000000000000000000000000

Expected behavior
u128 division to return expected calculated value

@hdriqi hdriqi added the bug Something isn't working label Jan 6, 2021
@willemneal
Copy link
Contributor

fixed by: #364

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working T-dev-tools
Projects
None yet
Development

No branches or pull requests

2 participants