Skip to content

`Numeric.showEFloat` does not honor precision with 0 digits

Hello,

Numeric.showEFloat should display a number of digit after the dot depending on the Maybe Int argument. It works for values > 0:

Prelude Numeric> Numeric.showEFloat (Just 5) pi ""
"3.14159e0"
Prelude Numeric> Numeric.showEFloat (Just 1) pi ""
"3.1e0"

But for 0 it shows the same result as with 1:

Prelude Numeric> Numeric.showEFloat (Just 0) pi ""
"3.1e0"

I was expecting 3e0 or 3e0.

As a matter of comparison, here is the behavior with Numeric.showFFloat:

Prelude Numeric> Numeric.showFFloat (Just 5) pi ""
"3.14159"
Prelude Numeric> Numeric.showFFloat (Just 1) pi ""
"3.1"
Prelude Numeric> Numeric.showFFloat (Just 0) pi ""
"3"
Trac metadata
Trac field Value
Version 8.4.2
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component libraries/base
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information