Skip to content

Conversation

@linco95
Copy link

@linco95 linco95 commented Aug 16, 2022

#192

The issue seemed to be that number | 0 !== number to detect integers doesn't work for big numbers. I replaced it with the Number.isInteger function, which seems to handle all test cases quite well

Also inverted the ternary operator to avoid the negation. I also suggest replacing multipleOf.toString().split('.').pop().length with a named function

const getDecimalPart = (num) => num.toString().split(".").pop();
const getNumberOfDecimals = (num) => getDecimalPart(num).length;

var factor = Number.isInteger(multipleOf) ? 1 : Math.pow(10, getNumberOfDecimals(multipleOf))

@linco95
Copy link
Author

linco95 commented Aug 16, 2022

Closes #192

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