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
Instances13Eq, Fractional, Data, Num, Ord, Read, …
Eq ScientificDefined in scientific-0.3.8.0 · Data.ScientificScientific numbers can be safely compared for equality. No magnitude
10^eis calculated so there's no risk of a blowup in space or time when comparing scientific numbers coming from untrusted sources.Fractional ScientificDefined in scientific-0.3.8.0 · Data.ScientificWARNING: recip and / will throw an error when their outputs are repeating decimals.
These methods also compute Integer magnitudes (
10^e). If these methods are applied to arguments which have huge exponents this could fill up all space and crash your program! So don't apply these methods to scientific numbers coming from untrusted sources.fromRational will throw an error when the input Rational is a repeating decimal. Consider using fromRationalRepetend for these rationals which will detect the repetition and indicate where it starts.
Data ScientificDefined in scientific-0.3.8.0 · Data.ScientificNum ScientificDefined in scientific-0.3.8.0 · Data.ScientificWARNING: + and - compute the Integer magnitude:
10^ewhereeis the difference between thebase10Exponentsof the arguments. If these methods are applied to arguments which have huge exponents this could fill up all space and crash your program! So don't apply these methods to scientific numbers coming from untrusted sources. The other methods can be used safely.Ord ScientificDefined in scientific-0.3.8.0 · Data.ScientificScientific numbers can be safely compared for ordering. No magnitude
10^eis calculated so there's no risk of a blowup in space or time when comparing scientific numbers coming from untrusted sources.Read ScientificDefined in scientific-0.3.8.0 · Data.ScientificSupports the skipping of parentheses and whitespaces. Example:
> read " ( (( -1.0e+3 ) ))" :: Scientific -1000.0(Note: This
Readinstance makes internal use of scientificP to parse the floating-point number.)Real ScientificDefined in scientific-0.3.8.0 · Data.ScientificWARNING: toRational needs to compute the Integer magnitude:
10^e. If applied to a huge exponent this could fill up all space and crash your program!Avoid applying toRational (or realToFrac) to scientific numbers coming from an untrusted source and use toRealFloat instead. The latter guards against excessive space usage.
RealFrac ScientificDefined in scientific-0.3.8.0 · Data.ScientificWARNING: the methods of the
RealFracinstance need to compute the magnitude10^e. If applied to a huge exponent this could take a long time. Even worse, when the destination type is unbounded (i.e. Integer) it could fill up all space and crash your program!Show ScientificDefined in scientific-0.3.8.0 · Data.ScientificSee formatScientific if you need more control over the rendering.
NFData ScientificDefined in scientific-0.3.8.0 · Data.ScientificBinary ScientificDefined in scientific-0.3.8.0 · Data.ScientificNote that in the future I intend to change the type of the base10Exponent from
InttoInteger. To be forward compatible theBinaryinstance already encodes the exponent as Integer.Hashable ScientificDefined in scientific-0.3.8.0 · Data.ScientificA hash can be safely calculated from a
Scientific. No magnitude10^eis calculated so there's no risk of a blowup in space or time when hashing scientific numbers coming from untrusted sources.Example4 expressions import Data.Hashable (hash)let x = scientific 1 2let y = scientific 100 0(x == y, hash x == hash y)(True,True)
Lift ScientificDefined in scientific-0.3.8.0 · Data.Scientific