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

UFix64 does not use Decimal #28

Open
uhbif19 opened this issue Aug 16, 2021 · 1 comment
Open

UFix64 does not use Decimal #28

uhbif19 opened this issue Aug 16, 2021 · 1 comment
Labels
bug Something isn't working examples Changed examples

Comments

@uhbif19
Copy link

uhbif19 commented Aug 16, 2021

UFix64 works like this:

In [7]: cadence.UFix64(1).encode()
Out[7]: {'type': 'UFix64', 'value': '0.00000001'}

This is binding library API to details of Flow (that UFix64 uses 8 decimals ) and is error-prone (thats why JSON-Cadence stores UFix64 as strings: https://docs.onflow.org/cadence/json-cadence-spec/#fixed-point-numbers).

If propose this API:

In [17]: UFix64(Decimal('123.4')).encode()
Out[17]: {'type': 'UFix64', 'value': '123.4'}```

If that change is okay, I can make a PR.

@janezpodhostnik
Copy link
Owner

That is a good point. I did not notice.

A PR would be wonderful, thank you very much!

@janezpodhostnik janezpodhostnik added examples Changed examples bug Something isn't working labels Aug 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working examples Changed examples
Projects
None yet
Development

No branches or pull requests

2 participants