Copyright | (c) 2011 MailRank Inc. |
---|---|
License | BSD-style |
Maintainer | bos@serpentine.com |
Stability | experimental |
Portability | GHC |
Safe Haskell | Safe-Inferred |
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 can 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 via Builder (both in the in case of bytestring and text) in case of single number is a bit slower, than to text or bytestring directly. But conversion a large amount of numbers to text via Builder (for example using foldr) is much faster than direct conversion to Text (up to 10-15x).
The same works for bytestrings: conversion, for example, a list of 20000 doubles to bytestring builder and then to bytestring is about 13 times faster than direct conversion of this list to bytestring.
Conversion to text via text builder is a little bit slower, than conversion to bytestring 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 Builder Source # | |
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 Text Source # | |
Convertable Double Builder Source # | |
Convertable Float Builder 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 Text Source # | |
Convertable Float Builder Source # | |