floatshow-0.2.4: Alternative faster String representations for Double and Float, String representations for more general numeric types.

Copyright(c) 2011 Daniel Fischer
LicenseBSD3
MaintainerDaniel Fischer
Stabilityexperimental
Portabilitynon-portable (GHC extensions)
Safe HaskellNone
LanguageHaskell98

Text.FShow.RealFloat

Description

Faster String representations for floating point types. The code is largely taken from code in GHC.Float and the Show instance of Integer in GHC.Num to get the sequence of digits.

Synopsis

Documentation

class FShow a where #

A duplicate of the Show class.

Minimal complete definition

Nothing

Methods

fshow :: a -> String #

fshowsPrec :: Int -> a -> ShowS #

fshowList :: [a] -> ShowS #

Instances
FShow Double # 
Instance details

Defined in Text.FShow.RealFloat

FShow Float # 
Instance details

Defined in Text.FShow.RealFloat

FShow FullFloat # 
Instance details

Defined in Text.FShow.RealFloat

FShow Float7 # 
Instance details

Defined in Text.FShow.RealFloat

FShow FullDouble # 
Instance details

Defined in Text.FShow.RealFloat

FShow Double7 # 
Instance details

Defined in Text.FShow.RealFloat

FShow a => FShow [a] # 
Instance details

Defined in Text.FShow.RealFloat

Methods

fshow :: [a] -> String #

fshowsPrec :: Int -> [a] -> ShowS #

fshowList :: [[a]] -> ShowS #

fshows :: FShow a => a -> ShowS #

Same as shows, but using an FShow instance.

class RealFloat a => DispFloat a where #

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 binExp x = floatDigits x - 1. The number of decimal digits that may be required is calculated with the formula

  decDigits x = 2 + floor (floatDigits x * logBase 10 2).

The default implementation uses an approximation of logBase 10 2 sufficient for mantissae of up to several thousand bits. Nevertheless, hardcoding the values in instance declarations may yield better performance.

Minimal complete definition

Nothing

Methods

decDigits :: a -> Int #

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.

binExp :: a -> Int #

The base 2 logarithm of the mantissa returned by decodeFloat x for x > 0.

Instances
DispFloat Double # 
Instance details

Defined in Text.FShow.RealFloat

Methods

decDigits :: Double -> Int #

binExp :: Double -> Int #

DispFloat Float # 
Instance details

Defined in Text.FShow.RealFloat

Methods

decDigits :: Float -> Int #

binExp :: Float -> Int #

DispFloat FullFloat # 
Instance details

Defined in Text.FShow.RealFloat

DispFloat Float7 # 
Instance details

Defined in Text.FShow.RealFloat

Methods

decDigits :: Float7 -> Int #

binExp :: Float7 -> Int #

DispFloat FullDouble # 
Instance details

Defined in Text.FShow.RealFloat

DispFloat Double7 # 
Instance details

Defined in Text.FShow.RealFloat

Methods

decDigits :: Double7 -> Int #

binExp :: Double7 -> Int #

fshowFloat :: DispFloat a => a -> ShowS #

Show a signed DispFloat value to full precision using standard decimal notation for arguments whose absolute value lies between 0.1 and 9,999,999, and scientific notation otherwise. Analogous to showFloat from GHC.Float.

fshowEFloat :: DispFloat a => Maybe Int -> a -> ShowS #

Show a signed DispFloat value using scientific (exponential) notation (e.g. 2.45e2, 1.5e-3).

In the call fshowEFloat digs val, if digs is Nothing, the value is shown to full precision; if digs is Just d, then max 1 d digits after the decimal point are shown. Analogous to showEFloat from Numeric.

fshowFFloat :: DispFloat a => Maybe Int -> a -> ShowS #

Show a signed DispFloat value using standard decimal notation (e.g. 245000, 0.0015).

In the call fshowFFloat digs val, if digs is Nothing, the value is shown to full precision; if digs is Just d, then max 0 d digits after the decimal point are shown. Analogous to showFFloat from Numeric.

fshowGFloat :: DispFloat a => Maybe Int -> a -> ShowS #

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 fshowGFloat digs val, if digs is Nothing, the value is shown to full precision; if digs is Just d, then max 1 d digits after the decimal point are shown. Analogous to showGFloat from Numeric.

newtype Double7 #

newtype wrapper for Double. The Show (and FShow) instance displays numbers rounded to seven significant digits.

Constructors

D7 Double 
Instances
Eq Double7 # 
Instance details

Defined in Text.FShow.RealFloat

Methods

(==) :: Double7 -> Double7 -> Bool #

(/=) :: Double7 -> Double7 -> Bool #

Floating Double7 # 
Instance details

Defined in Text.FShow.RealFloat

Fractional Double7 # 
Instance details

Defined in Text.FShow.RealFloat

Num Double7 # 
Instance details

Defined in Text.FShow.RealFloat

Ord Double7 # 
Instance details

Defined in Text.FShow.RealFloat

Real Double7 # 
Instance details

Defined in Text.FShow.RealFloat

RealFloat Double7 # 
Instance details

Defined in Text.FShow.RealFloat

RealFrac Double7 # 
Instance details

Defined in Text.FShow.RealFloat

Methods

properFraction :: Integral b => Double7 -> (b, Double7) #

truncate :: Integral b => Double7 -> b #

round :: Integral b => Double7 -> b #

ceiling :: Integral b => Double7 -> b #

floor :: Integral b => Double7 -> b #

Show Double7 # 
Instance details

Defined in Text.FShow.RealFloat

FShow Double7 # 
Instance details

Defined in Text.FShow.RealFloat

DispFloat Double7 # 
Instance details

Defined in Text.FShow.RealFloat

Methods

decDigits :: Double7 -> Int #

binExp :: Double7 -> Int #

newtype FullDouble #

newtype wrapper for Double. The Show (and FShow) instance displays all significant digits.

Constructors

FD 

Fields

Instances
Eq FullDouble # 
Instance details

Defined in Text.FShow.RealFloat

Floating FullDouble # 
Instance details

Defined in Text.FShow.RealFloat

Fractional FullDouble # 
Instance details

Defined in Text.FShow.RealFloat

Num FullDouble # 
Instance details

Defined in Text.FShow.RealFloat

Ord FullDouble # 
Instance details

Defined in Text.FShow.RealFloat

Read FullDouble # 
Instance details

Defined in Text.FShow.RealFloat

Real FullDouble # 
Instance details

Defined in Text.FShow.RealFloat

RealFloat FullDouble # 
Instance details

Defined in Text.FShow.RealFloat

RealFrac FullDouble # 
Instance details

Defined in Text.FShow.RealFloat

Show FullDouble # 
Instance details

Defined in Text.FShow.RealFloat

FShow FullDouble # 
Instance details

Defined in Text.FShow.RealFloat

DispFloat FullDouble # 
Instance details

Defined in Text.FShow.RealFloat

newtype Float7 #

newtype wrapper for Float. The Show (and FShow) instance displays numbers rounded to seven significant digits.

Constructors

F7 Float 
Instances
Eq Float7 # 
Instance details

Defined in Text.FShow.RealFloat

Methods

(==) :: Float7 -> Float7 -> Bool #

(/=) :: Float7 -> Float7 -> Bool #

Floating Float7 # 
Instance details

Defined in Text.FShow.RealFloat

Fractional Float7 # 
Instance details

Defined in Text.FShow.RealFloat

Num Float7 # 
Instance details

Defined in Text.FShow.RealFloat

Ord Float7 # 
Instance details

Defined in Text.FShow.RealFloat

Real Float7 # 
Instance details

Defined in Text.FShow.RealFloat

RealFloat Float7 # 
Instance details

Defined in Text.FShow.RealFloat

RealFrac Float7 # 
Instance details

Defined in Text.FShow.RealFloat

Methods

properFraction :: Integral b => Float7 -> (b, Float7) #

truncate :: Integral b => Float7 -> b #

round :: Integral b => Float7 -> b #

ceiling :: Integral b => Float7 -> b #

floor :: Integral b => Float7 -> b #

Show Float7 # 
Instance details

Defined in Text.FShow.RealFloat

FShow Float7 # 
Instance details

Defined in Text.FShow.RealFloat

DispFloat Float7 # 
Instance details

Defined in Text.FShow.RealFloat

Methods

decDigits :: Float7 -> Int #

binExp :: Float7 -> Int #

newtype FullFloat #

newtype wrapper for Double. The Show (and FShow) instance displays all significant digits.

Constructors

FF 

Fields

Instances
Eq FullFloat # 
Instance details

Defined in Text.FShow.RealFloat

Floating FullFloat # 
Instance details

Defined in Text.FShow.RealFloat

Fractional FullFloat # 
Instance details

Defined in Text.FShow.RealFloat

Num FullFloat # 
Instance details

Defined in Text.FShow.RealFloat

Ord FullFloat # 
Instance details

Defined in Text.FShow.RealFloat

Read FullFloat # 
Instance details

Defined in Text.FShow.RealFloat

Real FullFloat # 
Instance details

Defined in Text.FShow.RealFloat

RealFloat FullFloat # 
Instance details

Defined in Text.FShow.RealFloat

RealFrac FullFloat # 
Instance details

Defined in Text.FShow.RealFloat

Show FullFloat # 
Instance details

Defined in Text.FShow.RealFloat

FShow FullFloat # 
Instance details

Defined in Text.FShow.RealFloat

DispFloat FullFloat # 
Instance details

Defined in Text.FShow.RealFloat