sci-ratio-0.2.0.0: Rational numbers in scientific notation.

Stabilityexperimental
Safe HaskellNone

Data.SciRatio.Show

Contents

Description

The functions here pretty-print numbers in a compact format. Examples:

>>> showSciRational (-0.0e+3)         -- result: "0"
>>> showSciRational (0.25e+2)         -- result: "25"
>>> showSciRational (-1.0e-1)         -- result: "-.1"
>>> showSciRational (5.0e+20 / 6)     -- result: "2.5e20/3"
>>> showSciRational (0xfeedface)      -- result: "4277009102"
>>> showSciRational (1 .^ 99999999)   -- result: "1e99999999"

__Note__: Without taking optimizations into account, the specialized functions (showSciRational and showsSciRational) are much more efficient than the generic functions (showNumber and showsNumber respectively).

Synopsis

Simple pretty-printers

showNumber :: Real a => a -> StringSource

Show a number (see showsNumber).

Note: for SciRational, consider using the more efficient, specialized function showSciRational instead.

ShowS pretty-printers

showsNumber :: Real a => a -> ShowSSource

Show a rational number in scientific notation:

 [-+]?
 ( [0-9]+ [.]? [0-9]* | [.] [0-9]+ )
 ( [e] [-+]? [0-9]+ )?
 ( [/] [0-9]+ )?

Note: for SciRational, consider using the more efficient, specialized function showsSciRational instead.