Skip to content

Leave out the period in formatRealFloat Exponent (Just 0) - #726

Open
Lotion-3 wants to merge 1 commit into
haskell:masterfrom
Lotion-3:exponent-zero-decimals
Open

Lotion-3 wants to merge 1 commit into
haskell:masterfrom
Lotion-3:exponent-zero-decimals

Conversation

@Lotion-3

Copy link
Copy Markdown

Fixes #231.

formatRealFloat Exponent (Just 0) shows one decimal, so it gives the same output as Just 1. Since base-4.12 (GHC#15115), showEFloat (Just 0) leaves out the decimals and the period:

>>> toLazyText (formatRealFloat Exponent (Just 0) 7.889773721040559e213)
"7.9e213"        -- showEFloat (Just 0): "8e213"

This ports GHC's case for no decimals, and removes the gh-231 special cases from the formatRealFloat property; they're now only skipped for base < 4.12, which still shows one decimal. Generic with Just 0 is fixed too, since it formats through Exponent.

As noted in #231, this changes output, so it's for the next major version. Happy to leave it until then.

tb_formatRealFloat_float and tb_formatRealFloat_double pass 200,000 cases each, and fail on master with the updated property.

With no decimals, formatRealFloat Exponent showed one decimal anyway, so (Just 0) gave the same output as (Just 1). showEFloat leaves out the decimals and the period since base-4.12 (GHC#15115). This does the same, and removes the special cases for haskellgh-231 from the tests.
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.

Port over GHC#15115 to text

1 participant