Copyright | (c) 2011 MailRank Inc. |
---|---|
License | BSD-style |
Maintainer | bos@serpentine.com |
Stability | experimental |
Portability | GHC |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- class (RealFloat a, IsString b) => Convertable a b where
- toExponential :: Int -> a -> b
- toPrecision :: Int -> a -> b
- toFixed :: Int -> a -> b
- toShortest :: a -> b
Documentation
class (RealFloat a, IsString b) => Convertable a b where Source #
Type class for floating data types, that cen be converted, using double-conversion library
Default instanced convert input to Double and then make Bytestring Builder from it.
list of functions :
toExponential: Compute a representation in exponential format with the requested number of digits after the decimal point. The last emitted digit is rounded. If -1 digits are requested, then the shortest exponential representation is computed.
toPrecision:
Compute precision
leading digits of the given value either in
exponential or decimal format. The last computed digit is rounded.
toFixed: Compute a decimal representation with a fixed number of digits after the decimal point. The last emitted digit is rounded.
toShortest: Compute the shortest string of digits that correctly represent the input number.
Conversion to text is twice faster than conversion to bytestring Conversion to text via Builder (both in the in case of bytestring and text) in case of single number is much slower, than to text or bytestring directly. (2-3x) But conversion large amount of numbers to text via Builder is much faster than directly (up to 50x). Conversion to text via text builder is a little slower, then via bytestring builder
Nothing
toExponential :: Int -> a -> b Source #
default toExponential :: b ~ Builder => Int -> a -> b Source #
toPrecision :: Int -> a -> b Source #
default toPrecision :: b ~ Builder => Int -> a -> b Source #
toFixed :: Int -> a -> b Source #
toShortest :: a -> b Source #
default toShortest :: b ~ Builder => a -> b Source #
Instances
Convertable Double ByteString Source # | |
Defined in Data.Double.Conversion.Convertable toExponential :: Int -> Double -> ByteString Source # toPrecision :: Int -> Double -> ByteString Source # toFixed :: Int -> Double -> ByteString Source # toShortest :: Double -> ByteString Source # | |
Convertable Double Builder Source # | |
Convertable Double Builder Source # | |
Convertable Double Text Source # | |
Convertable Float ByteString Source # | |
Defined in Data.Double.Conversion.Convertable toExponential :: Int -> Float -> ByteString Source # toPrecision :: Int -> Float -> ByteString Source # toFixed :: Int -> Float -> ByteString Source # toShortest :: Float -> ByteString Source # | |
Convertable Float Builder Source # | |
Convertable Float Builder Source # | |
Convertable Float Text Source # | |