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

fix(round): Throw an exception when precision is not an integer #79

Merged
merged 3 commits into from
Jun 20, 2024

Conversation

westofsky
Copy link
Contributor

Description

When rounding, the type of the second parameter, precision, is Number, which can also accept float values. Therefore, I added exception handling for cases where it is not an Integer.

Changes

When attempting to use the round function with inputs like round(1.2345, 3.1), the result was 1.2343860767615331, which does not behave as desired for a rounding function. To fix this, I added exception handling with the following code.

if (!Number.isInteger(precision)) {
  throw new Error('Precision must be an integer.');
}

This ensures that the precision parameter must be an integer, preventing incorrect rounding behavior.

@westofsky westofsky requested a review from raon0211 as a code owner June 19, 2024 17:47
Copy link

vercel bot commented Jun 19, 2024

@westofsky is attempting to deploy a commit to the Toss Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Collaborator

@raon0211 raon0211 left a comment

Choose a reason for hiding this comment

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

Thanks!

@raon0211 raon0211 changed the title feat(round): Add exception for precision fix(round): Throw an exception when precision is not an integer Jun 20, 2024
@raon0211 raon0211 merged commit 92c9db0 into toss:main Jun 20, 2024
5 of 6 checks passed
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 this pull request may close these issues.

2 participants