| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Data.FormatN
Description
Formatting of Doubles.
Synopsis
- data FormatN
- defaultFormatN :: FormatN
- fromFormatN :: IsString s => FormatN -> s
- toFormatN :: (Eq s, IsString s) => s -> Int -> FormatN
- fixed :: Int -> Double -> Text
- decimal :: Int -> Double -> Text
- prec :: Int -> Double -> Text
- comma :: Int -> Double -> Text
- expt :: Int -> Double -> Text
- dollar :: Int -> Double -> Text
- formatN :: FormatN -> Double -> Text
- precision :: (Int -> Double -> Text) -> Int -> [Double] -> [Text]
- formatNs :: FormatN -> [Double] -> [Text]
Documentation
Wrapper for the various formatting options.
>>>defaultFormatNFormatComma 2
Constructors
| FormatFixed Int | |
| FormatDecimal Int | |
| FormatComma Int | |
| FormatExpt Int | |
| FormatPrec Int | |
| FormatDollar Int | |
| FormatPercent Int | |
| FormatNone |
Instances
defaultFormatN :: FormatN Source #
The official format
fromFormatN :: IsString s => FormatN -> s Source #
type textifier
fixed :: Int -> Double -> Text Source #
to x decimal places
>>>fixed 2 1"1.00"
>>>fixed 2 0.001"0.00"
decimal :: Int -> Double -> Text Source #
round to n significant figures and always use decimal notation
>>>decimal 2 0.000001234"0.00000123"
>>>decimal 2 1234567"1230000"
prec :: Int -> Double -> Text Source #
format numbers between 0.001 and 1,000,000 using digit and comma notation and exponential outside this range, with x significant figures.
>>>prec 1 0.00234"0.0023"
>>>prec 1 0.000023"2.3e-5"
>>>prec 1 123"120"
>>>prec 1 123456"120000"
>>>prec 1 1234567"1.2e6"
comma :: Int -> Double -> Text Source #
add commas format for numbers above 1,000 but below 1 million, otherwise use prec.
>>>comma 2 1234"1,230"
dollar :: Int -> Double -> Text Source #
dollars and cents, always decimal notation
>>>dollar 2 1234"$1,230"
>>>dollar 2 0.01234"$0.0123"