Skip to content

Comments

Fixed invalid behaviour of numbersToExpressions option for float numbers#885

Merged
sanex3339 merged 2 commits intomasterfrom
numbers-to-expressions-float
Feb 25, 2021
Merged

Fixed invalid behaviour of numbersToExpressions option for float numbers#885
sanex3339 merged 2 commits intomasterfrom
numbers-to-expressions-float

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