double-conversion-2.0.4.2: Fast conversion between single and double precision floating point and text
Copyright(c) 2011 MailRank Inc.
LicenseBSD-style
Maintainerbos@serpentine.com
Stabilityexperimental
PortabilityGHC
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Double.Conversion.Convertable

Description

 
Synopsis

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.

Minimal complete definition

Nothing

Methods

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 #

default toFixed :: b ~ Builder => Int -> a -> b Source #

toShortest :: a -> b Source #

default toShortest :: b ~ Builder => a -> b Source #

Instances

Instances details
Convertable Double Builder Source # 
Instance details

Defined in Data.Double.Conversion.Convertable

Convertable Double ByteString Source # 
Instance details

Defined in Data.Double.Conversion.Convertable

Convertable Double Text Source # 
Instance details

Defined in Data.Double.Conversion.Convertable

Convertable Double Builder Source # 
Instance details

Defined in Data.Double.Conversion.Convertable

Convertable Float Builder Source # 
Instance details

Defined in Data.Double.Conversion.Convertable

Convertable Float ByteString Source # 
Instance details

Defined in Data.Double.Conversion.Convertable

Convertable Float Text Source # 
Instance details

Defined in Data.Double.Conversion.Convertable

Convertable Float Builder Source # 
Instance details

Defined in Data.Double.Conversion.Convertable