Skip to content

Fixed invalid behaviour of numbersToExpressions option for float numbers #885

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

Merged
merged 2 commits into from
Feb 25, 2021

Conversation

sanex3339
Copy link
Member

Fixed invalid behaviour of numbersToExpressions option for float numbers

Fixed #882

* @returns {[number, (number | null)]}
*/
public static extractIntegerAndDecimalParts (number: number): [number, number | null] {
const integerPart: number = Math.floor(number);
Copy link

Choose a reason for hiding this comment

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

I think this line should be Math.trunc(number) instead of floor: otherwise for number = -1e-100 you would get [-1, -1e-100].
(I heard that Math.trunc doesn't work for IE; if that's an issue, maybe use number >= 0 ? Math.floor : Math.ceil)

@sanex3339 sanex3339 merged commit 40dac43 into master Feb 25, 2021
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.

"Numbers to expressions" incorrect for small numbers
2 participants