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

Inconsistent use of 'e' vs 'E' in formatting numbers #131

Open
gnp opened this issue Jul 18, 2024 · 2 comments
Open

Inconsistent use of 'e' vs 'E' in formatting numbers #131

gnp opened this issue Jul 18, 2024 · 2 comments

Comments

@gnp
Copy link

gnp commented Jul 18, 2024

Examples (the non-parenthetical representation is a string used to construct the BigDecimal):

    "large_float": 1.7976931348623157e308 (BigDecimal: 17976931348623157e+292)
    "small_float": 4.9406564584124654e-324 (BigDecimal: 4.9406564584124654E-324)

I looked through the source for the formatting and it appears "e" is the majority case but existing test cases check for "E" in a couple places.

@akubera
Copy link
Owner

akubera commented Jul 20, 2024

The distinction should be here in this if statement:

if leading_zero_threshold < leading_zero_count {

(All of the formatting code should be in that impl_fmt.rs file)

The upper E is properly written in scientific notation (with decimal point after first digit) vs the lower e is for "integer" exponents (for large exponents), where no decimal point is added. This isn't documented anywhere, just my ad-hoc convention.

Is this causing issues with something?

@akubera
Copy link
Owner

akubera commented Jul 20, 2024

I'll note you can force one or the other via formatting {:e} for {:E} for consistent scientific notation.

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

No branches or pull requests

2 participants