Data.Text.Lazy.Builder.RealFloat

text-1.2.3.1: An efficient packed Unicode text type.

Copyright | (c) The University of Glasgow 1994-2002
License | see libraries/base/LICENSE
Safe Haskell | Trustworthy
Language | Haskell98

Data.Text.Lazy.Builder.RealFloat

Description

Write a floating point value to a `Builder`.

Synopsis

- data FPFormat
  - = Exponent
  - | Fixed
  - | Generic
- realFloat :: RealFloat a => a -> Builder
- formatRealFloat :: RealFloat a => FPFormat -> Maybe Int -> a -> Builder

# Documentation

data FPFormat #

Control the rendering of floating point numbers.

Constructors

Exponent | Scientific notation (e.g. `2.3e123`).
Fixed | Standard decimal notation.
Generic | Use decimal notation for values between `0.1` and `9,999,999`, and scientific notation otherwise.

Instances

Enum FPFormat # |
Instance details Defined in Data.Text.Lazy.Builder.RealFloat Methods succ :: FPFormat -> FPFormat Source # pred :: FPFormat -> FPFormat Source # toEnum :: Int -> FPFormat Source # fromEnum :: FPFormat -> Int Source # enumFrom :: FPFormat -> [FPFormat] Source # enumFromThen :: FPFormat -> FPFormat -> [FPFormat] Source # enumFromTo :: FPFormat -> FPFormat -> [FPFormat] Source # enumFromThenTo :: FPFormat -> FPFormat -> FPFormat -> [FPFormat] Source #
Read FPFormat # |
Instance details Defined in Data.Text.Lazy.Builder.RealFloat Methods readsPrec :: Int -> ReadS FPFormat Source # readList :: ReadS [FPFormat] Source # readPrec :: ReadPrec FPFormat Source # readListPrec :: ReadPrec [FPFormat] Source #
Show FPFormat # |
Instance details Defined in Data.Text.Lazy.Builder.RealFloat Methods showsPrec :: Int -> FPFormat -> ShowS Source # show :: FPFormat -> String Source # showList :: [FPFormat] -> ShowS Source #

realFloat :: RealFloat a => a -> Builder #

Show a signed `RealFloat` 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.

formatRealFloat #

Arguments

:: RealFloat a |
=> FPFormat |
-> Maybe Int | Number of decimal places to render.
-> a |
-> Builder |

Encode a signed `RealFloat` according to `FPFormat` and optionally requested precision.

This corresponds to the `show{E,F,G}Float` operations provided by `base`'s Numeric module.

NOTE: The functions in `base-4.12` changed the serialisation in case of a `Just 0` precision; this version of `text` still provides the serialisation as implemented in `base-4.11`. The next major version of `text` will switch to the more correct `base-4.12` serialisation.