Portability | GHC |
---|---|

Stability | experimental |

Maintainer | bos@serpentine.com |

Safe Haskell | Safe-Infered |

Fast, efficient support for converting between double precision floating point values and text.

Although about 15 times faster than plain `show`

, these functions
are *slower* than their `Text`

counterparts, at roughly half the
speed. (This seems to be due to the cost of allocating
`ByteString`

values via `malloc`

.)

- toExponential :: Int -> Double -> ByteString
- toFixed :: Int -> Double -> ByteString
- toPrecision :: Int -> Double -> ByteString
- toShortest :: Double -> ByteString

# Documentation

toExponential :: Int -> Double -> ByteStringSource

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.

toFixed :: Int -> Double -> ByteStringSource

Compute a decimal representation with a fixed number of digits after the decimal point. The last emitted digit is rounded.

toPrecision :: Int -> Double -> ByteStringSource

Compute `precision`

leading digits of the given value either in
exponential or decimal format. The last computed digit is rounded.

toShortest :: Double -> ByteStringSource

Compute the shortest string of digits that correctly represent the input number.