Fix bugs when formatting percentages
This commit is contained in:
parent
787a94c085
commit
01294fd24f
@ -26,12 +26,11 @@ formatTheResultWithErrorBounds format pointEstimate (Just errorBound) = (formatS
|
|||||||
|
|
||||||
formatSimpleResult :: FormattingOptions -> MetricValue -> String
|
formatSimpleResult :: FormattingOptions -> MetricValue -> String
|
||||||
formatSimpleResult = \case
|
formatSimpleResult = \case
|
||||||
FormattingOptions (Just prec) True -> printf "%.*f" (prec-2) . (*100)
|
FormattingOptions (Just prec) True -> printf "%.*f" (max 0 (prec-2)) . (*100)
|
||||||
FormattingOptions (Just prec) _ -> printf "%.*f" prec
|
FormattingOptions (Just prec) _ -> printf "%.*f" prec
|
||||||
_ -> show
|
_ -> show
|
||||||
|
|
||||||
selectLowerPrecision :: Int -> FormattingOptions -> FormattingOptions
|
selectLowerPrecision :: Int -> FormattingOptions -> FormattingOptions
|
||||||
selectLowerPrecision p = \case
|
selectLowerPrecision p = \case
|
||||||
a@(FormattingOptions _ True) -> a
|
FormattingOptions (Just prec) showAsPercentage -> FormattingOptions (Just $ min prec p) showAsPercentage
|
||||||
FormattingOptions (Just prec) _ -> FormattingOptions (Just $ min prec p) False
|
FormattingOptions (Nothing) showAsPercentage -> FormattingOptions (Just p) showAsPercentage
|
||||||
_ -> FormattingOptions (Just p) False
|
|
||||||
|
Loading…
Reference in New Issue
Block a user