Sitelet https://github.com/autoNumeric/autoNumeric/pull/836
Skip to content

Do not treat the minus sign in the scientific notation as a negative number, and better manage tiny percentages - #836

Merged
AlexandreBonneau merged 1 commit into
autoNumeric:nextfrom
SashaMIT:codered-tiny-percentage
Sep 27, 2026
Merged

AlexandreBonneau merged 1 commit into
autoNumeric:nextfrom
SashaMIT:codered-tiny-percentage

Conversation

@SashaMIT

Copy link
Copy Markdown
Contributor

Summary

Test plan

  • On tip, format(1e-19) was 10.000% and format(1e-10) was -1%
  • After the change those are 0.000%, and 0.1 is still 10.000%
  • Karma unit run was not executed here (it needs a browser). The new spec covers the same format calls

Made with Cursor

format of 1e-19 as a 3-decimal US percentage returned 10.000%. format of 1e-10 returned -1%. The exponent minus was read as the sign.
@AlexandreBonneau
AlexandreBonneau self-requested a review September 27, 2026 08:44
@AlexandreBonneau

Copy link
Copy Markdown
Member

I've tested the fix, and it works, thanks.
It would still be better to test your own (generated) code before creating a pull request.
It's not that hard (yarn test:unit) and might avoid necessary back and forth!

@AlexandreBonneau AlexandreBonneau changed the title Expand a tiny percentage before reading its sign Do not treat the minus sign in the scientific notation as a negative number, and better manage tiny percentages Sep 27, 2026
@AlexandreBonneau
AlexandreBonneau merged commit c1ad398 into autoNumeric:next Sep 27, 2026
@SashaMIT

Copy link
Copy Markdown
Contributor Author

Thanks for testing it and merging. You're right, I should have run yarn test:unit before opening this.

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.

The format function with the percentageUS3dec predefined option doesn't work properly when the input is a number and is sufficiently close to 0

2 participants