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

Eth.Units.fromWei does not work with negative numbers #68

Open
cmditch opened this issue Nov 28, 2018 · 2 comments
Open

Eth.Units.fromWei does not work with negative numbers #68

cmditch opened this issue Nov 28, 2018 · 2 comments

Comments

@cmditch
Copy link
Owner

cmditch commented Nov 28, 2018

> Maybe.map (EU.fromWei EU.Ether) (BigInt.fromString "20000000000000000000000")
Just "20000" : Maybe.Maybe String
> Maybe.map (EU.fromWei EU.Ether) (BigInt.fromString "-20000000000000000000000")
Just "000-20000" : Maybe.Maybe String
> 
@gary02
Copy link

gary02 commented Mar 17, 2022

so as with very big num:

> maxWei
 Pos (Magnitude [9639935,791312,4575840,564039,8466564,8532699,8687907,7098500,1954235,9237316,1579208,1])
> toString maxWei  
"115792089237316195423570985008687907853269984665640564039457584007913129639935"
> fromWei Gwei maxWei
"115792089237316195.129639935"
> fromWei Ether maxWei
"115792089.584007913129639935"

@gary02
Copy link

gary02 commented Mar 17, 2022

so as with very big num:

> maxWei
 Pos (Magnitude [9639935,791312,4575840,564039,8466564,8532699,8687907,7098500,1954235,9237316,1579208,1])
> toString maxWei  
"115792089237316195423570985008687907853269984665640564039457584007913129639935"
> fromWei Gwei maxWei
"115792089237316195.129639935"
> fromWei Ether maxWei
"115792089.584007913129639935"

-- There are under 10^27 wei in existance (so we safe for the next couple of millennia).

OK... maybe document should mention this detail

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants