scientific-0.2.0.2: Arbitrary-precision floating-point numbers represented using scientific notation

MaintainerBas van Dijk <v.dijk.bas@gmail.com>
Safe HaskellNone

Data.Scientific

Contents

Description

This module is designed to be imported qualified:

import Data.Scientific as Scientific

Synopsis

Documentation

data Scientific Source

An arbitrary-precision number represented using scientific notation.

This type describes the set of all Reals which have a finite decimal expansion.

A scientific number with coefficient c and base10Exponent e corresponds to the Fractional number: fromInteger c * 10 ^^ e

Instances

Eq Scientific 
Fractional Scientific

WARNING: recip and / will diverge when their outputs have an infinite decimal expansion. fromRational will diverge when the input Rational has an infinite decimal expansion.

Data Scientific 
Num Scientific 
Ord Scientific 
Read Scientific 
Real Scientific 
RealFrac Scientific 
Show Scientific 
Typeable Scientific 
NFData Scientific 
Hashable Scientific 

scientific :: Integer -> Int -> ScientificSource

scientific c e constructs a scientific number with coefficient c and base10Exponent e.

coefficient :: Scientific -> IntegerSource

The coefficient of a scientific number.

base10Exponent :: Scientific -> IntSource

The base-10 exponent of a scientific number.

Conversions

fromFloatDigits :: RealFloat a => a -> ScientificSource

Efficient and exact conversion from a RealFloat into a Scientific number.

Pretty printing

data FPFormat Source

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.

scientificBuilder :: Scientific -> BuilderSource

A Text Builder which renders a scientific number to full precision, using standard decimal notation for arguments whose absolute value lies between 0.1 and 9,999,999, and scientific notation otherwise.

formatScientificBuilderSource

Arguments

:: FPFormat 
-> Maybe Int

Number of decimal places to render.

-> Scientific 
-> Builder 

Like scientificBuilder but provides rendering options.

formatScientificSource

Arguments

:: FPFormat 
-> Maybe Int

Number of decimal places to render.

-> Scientific 
-> String 

Like show but provides rendering options.

toDecimalDigits :: Scientific -> ([Int], Int)Source

Similar to floatToDigits, toDecimalDigits takes a non-negative Scientific number, and returns a list of digits and a base-10 exponent. In particular, if x>=0, and

 toDecimalDigits x = ([d1,d2,...,dn], e)

then

  1. n >= 1
  2. x = 0.d1d2...dn * (10^^e)
  3. 0 <= di <= 9