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 round implementation support for numbers that have string representations that use exponential notation. #5341

Conversation

sflanker
Copy link
Contributor

Resolves #5340

Changes:

The round() function now uses multiplication and division by powers of 10 to implement rounding to a fixed number of decimal places instead of using string concatenation with exponent notation.

PR Checklist

  • npm run lint passes
  • [Unit tests] are included / update

Copy link
Contributor

@outofambit outofambit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks great to me! thank you for writing additional tests :)

i'll wait a couple days to merge so others can chime in if they have any concerns

@outofambit outofambit self-assigned this Jul 3, 2021
@limzykenneth
Copy link
Member

limzykenneth commented Jul 4, 2021

Only potential edge case I can see is that if n * multiplier is larger than what can be represented by JS Number it may give an unexpected outcome. Ignoring that, this is ok to merge.

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

Successfully merging this pull request may close these issues.

The round() function does not work when a number of digits is specified with very small numbers.
3 participants