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

Fixed point type fractional digit limit #4061

Closed
axic opened this issue May 4, 2018 · 3 comments
Closed

Fixed point type fractional digit limit #4061

axic opened this issue May 4, 2018 · 3 comments

Comments

@axic
Copy link
Member

axic commented May 4, 2018

Currently the limit is set at maximum 80 digits, that means the largest number representable would be
0.999999999999999999999999999999999999999999999999999999999999999999999999999999999 in the ufixed256x80 type, while the largest number fitting 256 bits is 115792089237316195423570985008687907853269984665640564039457584007913129639936.

999999999999999999999999999999999999999999999999999999999999999999999999999999999
is larger than
115792089237316195423570985008687907853269984665640564039457584007913129639936

It actually requires 266 bits (log2(pow(10, 80) - 1)). I think the proper limit is 77 digits.

Not to mention signed fixed point, where an extra bit must be reserved for the sign.

@randomnetcat
Copy link
Contributor

randomnetcat commented May 4, 2018

Raised in the course of #3389 while discussing conversions.
Possible issue: this could overflow a u256 of 10^(abs(from - to)), causing issues with conversions.
Concerns raised in Gitter:

  • Consider making it 76 instead instead of (possibly confusing) change based on signed or unsigned.
  • Consider making max number of decimal places lower based on number of bits such that 1 is always in range.

@chriseth
Copy link
Contributor

chriseth commented May 9, 2018

Could you please clarify what "it" mean? Is this about limiting the number of fractional digits in general, or depending on the bit size?

@randomnetcat
Copy link
Contributor

Sorry, yes I mean the limit on fractional digits by it.

@axic axic added this to Inbox in Backlog (non-breaking) via automation Jan 30, 2019
@axic axic closed this as completed Jan 15, 2021
Backlog (non-breaking) automation moved this from Inbox to Done Jan 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

3 participants