Maintainer | Bas van Dijk <v.dijk.bas@gmail.com> |
---|---|
Safe Haskell | None |
This module is designed to be imported qualified:
import Data.Scientific as Scientific
- data Scientific
- scientific :: Integer -> Int -> Scientific
- coefficient :: Scientific -> Integer
- base10Exponent :: Scientific -> Int
- fromFloatDigits :: RealFloat a => a -> Scientific
- data FPFormat
- scientificBuilder :: Scientific -> Builder
- formatScientificBuilder :: FPFormat -> Maybe Int -> Scientific -> Builder
- formatScientific :: FPFormat -> Maybe Int -> Scientific -> String
- toDecimalDigits :: Scientific -> ([Int], Int)
Documentation
data Scientific Source
An arbitrary-precision number represented using scientific notation.
This type describes the set of all
which have a finite
decimal expansion.
Real
s
A scientific number with coefficient
c
and base10Exponent
e
corresponds to the Fractional
number: fromInteger
c * 10 ^^
e
Eq Scientific | |
Fractional Scientific | WARNING: |
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
Control the rendering of floating point numbers.
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.
:: FPFormat | |
-> Maybe Int | Number of decimal places to render. |
-> Scientific | |
-> Builder |
Like scientificBuilder
but provides rendering options.
:: 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
n >= 1
x = 0.d1d2...dn * (10^^e)
0 <= di <= 9