HORIZON HASKELLDocslts/ghc-9.14.x3e2d5682026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · 3e2d568 · 2026-10-11

Moduledouble-conversion-2.0.5.0Haskell2010

Data.Double.Conversion.Convertable

  • 1 class
classclass (RealFloat a, IsString b) => Convertable a b where
#

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.

Methods

Instances8Convertable, …