Portability | non-portable (GHC extensions) |
---|---|
Stability | experimental |
Maintainer | Daniel Fischer |
- class FShow a where
- fshows :: FShow a => a -> ShowS
- class RealFloat a => DispFloat a where
- fshowFloat :: DispFloat a => a -> ShowS
- fshowEFloat :: DispFloat a => Maybe Int -> a -> ShowS
- fshowFFloat :: DispFloat a => Maybe Int -> a -> ShowS
- fshowGFloat :: DispFloat a => Maybe Int -> a -> ShowS
- newtype Double7 = D7 Double
- newtype Float7 = F7 Float
Documentation
A duplicate of the Show
class.
class RealFloat a => DispFloat a whereSource
Class for specifying display parameters. The type a
is supposed to be an IEEE-ish (real) floating-point
type with floating-point radix 2, such that the mantissa
returned by decodeFloat
satisfies
2^(binExp
x) <=fst
(decodeFloat
x) < 2^(binExp
x + 1)
for x > 0
, so
.
The number of decimal digits that may be required is calculated
with the formula
binExp
x = floatDigits
x - 1
decDigits
x = 2 +floor
(floatDigits
x *logBase
10 2).
The default implementation uses an approximation of
sufficient for mantissae of up to
several thousand bits. Nevertheless, hardcoding
the values in instance declarations may yield
better performance.
logBase
10 2
The number of decimal digits that may be needed to
uniquely determine a value of type a
.
For faster conversions which need not satisfy
x ==read
(fshow
x)
a smaller value can be given.
The base 2 logarithm of the mantissa returned by
for decodeFloat
xx > 0
.
fshowFloat :: DispFloat a => a -> ShowSSource
fshowGFloat :: DispFloat a => Maybe Int -> a -> ShowSSource
Show a signed DispFloat
value
using standard decimal notation for arguments whose absolute value lies
between 0.1
and 9,999,999
, and scientific notation otherwise.
In the call
, if fshowGFloat
digs valdigs
is Nothing
,
the value is shown to full precision; if digs
is
,
then Just
d
digits after the decimal point are shown.
Analogous to max
1 d
from Numeric.
showGFloat