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

rounding 9.9 gives improper coefficient #191

Closed
lx-0 opened this issue Jul 8, 2022 · 1 comment
Closed

rounding 9.9 gives improper coefficient #191

lx-0 opened this issue Jul 8, 2022 · 1 comment

Comments

@lx-0
Copy link

lx-0 commented Jul 8, 2022

When rounding Big('9.9'), the resulting Big object will be:

Big {
  s: 1,
  e: 1,
  c: [ 1, '-1': NaN ],
  constructor: [Function: Big] {
    DP: 20,
    RM: 1,
    NE: -7,
    PE: 21,
    strict: true,
    roundDown: 0,
    roundHalfUp: 1,
    roundHalfEven: 2,
    roundUp: 3,
    Big: [Circular],
    default: [Circular]
  }
}

The index -1 of c is NaN.

@MikeMcl
Copy link
Owner

MikeMcl commented Jul 9, 2022

Thanks for the report. This bug seems to have been present from the beginning. 'Improper' is the right word.

To reassure other readers, this has no effect on the API or any normal usage of the library.

The bug adds an unwanted property named '-1' with value NaN to the coefficient array of a Big number returned by round when a Big number with a leading nine or nines is rounded up to a Big number which is a power of ten, such as 99.5 rounded up to 100. The unwanted property does not affect the length of the coefficent array or the Big number's value or any operations performed on it.

Thanks again. Fixed in v6.2.1.

@MikeMcl MikeMcl closed this as completed Jul 9, 2022
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

Successfully merging a pull request may close this issue.

2 participants