File tree 2 files changed +4
-4
lines changed
2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -73,10 +73,9 @@ shortest = fromString . toShortest . realToFrac
73
73
where
74
74
toShortest :: Double -> String
75
75
toShortest dbl =
76
- -- `showFFloat (Just 0) "" 1.0` gives "1.", but we want "1"
77
- let intPart = (floor dbl :: Int ) in
78
- if dbl == (fromIntegral intPart)
79
- then showInt intPart " "
76
+ let intPart = fromIntegral (floor dbl :: Int ) in
77
+ if dbl == intPart
78
+ then showFFloat (Just 0 ) intPart " "
80
79
else showFFloat Nothing dbl " "
81
80
#endif
82
81
{-# INLINE shortest #-}
Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ spec = do
49
49
it " Fixed" $ format (fixed 4 ) (12.123456 :: Double ) `shouldBe` " 12.1235"
50
50
it " Variable" $ format float (12.123456 :: Double ) `shouldBe` " 12.123456"
51
51
it " Shortest" $ format shortest (12.0000 :: Double ) `shouldBe` " 12"
52
+ it " Negative" $ format float (- 1.0000 :: Double ) `shouldBe` " -1"
52
53
53
54
describe " Scientific" $ do
54
55
it " sci" $ format sci (scientific 60221409 16 ) `shouldBe` " 6.0221409e23"
You can’t perform that action at this time.
0 commit comments