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

Locale: calling formatNumber with maximumfraction 15 and rounding returns strange number #5622

Closed
Sovia opened this issue Sep 16, 2021 · 8 comments · Fixed by #5625 or #5633
Closed
Assignees
Labels
priority: high status: clarification Issue needs clarification type: bug 🐛 [3] Velocity rating (Fibonacci)

Comments

@Sovia
Copy link
Contributor

Sovia commented Sep 16, 2021

Describe the bug
Calling formatNumber with a maxiumFraction/minimumFraction of 15 and round: true is returning an incorrect value.

To Reproduce

Steps to reproduce the behavior:

  1. Copy test-format-number-15-decimal.zip into the codebase
  2. Navigate to /components/locale/test-format-number-15-decimal.html
  3. Enter the value "123.54"
  4. See error

Expected behavior
The value in after calling formatNumber should be "123.540000000000000", not "123.540000000000006"

Version

  • ids-enterprise: v4.56.0-dev

Screenshots
FormatNumberIssue

Platform

  • Infor Application/Team Name: LMClient
  • All
@Sovia
Copy link
Contributor Author

Sovia commented Sep 16, 2021

This issue happens starting with 14 fraction digits

@vonnyw
Copy link
Contributor

vonnyw commented Sep 16, 2021

image
Actually it happens on numbers with high number of precision not starting with 14. It starts breaking when entering more digit before the decimal. The attached shows the maximum digit can be entered without rounding error.

@tmcconechy
Copy link
Member

Putting this note on:

10 digits precision, the maximum digits before the decimal is 7, 
11 digits precision, the maximum digits before the decimal is 5,
12 digits precision, the maximum digits before the decimal is 4,
13 digits precision, the maximum digits before the decimal is 3,
14 digits precision, the maximum digits before the decimal is 2,
15 digits precision, the maximum digits before the decimal is 1,

Whats the priority here?

@tmcconechy
Copy link
Member

Need one more fix which is not working

31.15

  • 16 digits on left, 77 decimal should not round to 80
    1234567890123456.77 -> 1234567890123456.770000000000000

@tmcconechy
Copy link
Member

Putting this on hold for now as i found it is working.

Soho.Locale.formatNumber('1234567890123456.77', { decimal: '.', group: '', maximumFractionDigits: 15, minimumFractionDigits: 15, round: false, style: 'decimal'})

So it will work if its a string since its a large number we need to do this. Because if you just paste 1234567890123456.77 JS will immediately round it as the number is too big for it.

@tmcconechy
Copy link
Member

tmcconechy commented Sep 21, 2021

Two more test cases

Soho.Locale.formatNumber("1234567890123456.77000000000000000", {style: 'decimal', round: true, minimumFractionDigits: 15, maximumFractionDigits: 15})

Get: '1.234.567.890.NaN.000.000.000.000.000'
Expect: '1.234.567.890.123.456,770000000000000'
  • Case 2
Soho.Locale.formatNumber('1234567890123456.77', { decimal: '.', group: '', maximumFractionDigits: 15, minimumFractionDigits: 15, round: false, style: 'decimal'})

Get: "123456789012345677.000000000000000"
Expect: "1234567890123456.77000000000000000"

@pwpatton
Copy link
Contributor

Basically it's any locale that use a comma ',' for a decimal separator and a period '.' for a group separator.

There are numerous locales that have that (about 20 in all).
da-DK, da-DE, el-GR, es-AR, es-ES, etc...

@EdwardCoyle EdwardCoyle moved this from To do to Ready for QA (beta) in Enterprise 4.56.x (Sept 2021) Sprint Sep 22, 2021
@janahintal janahintal moved this from Ready for QA (beta) to Done in Enterprise 4.56.x (Sept 2021) Sprint Sep 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: high status: clarification Issue needs clarification type: bug 🐛 [3] Velocity rating (Fibonacci)
Projects
No open projects
5 participants