úΠ›x     None<None<%Unsafe conversion for decimal digits.NoneNone<!Only defined for positive inputs! Power of an ÿ/ by the left-to-right repeated squaring algorithm. This needs two multiplications in each step while the right-to-left algorithm needs only one multiplication for 0-bits, but here the two factors always have approximately the same size, which on average gains a bit when the result is large.ÿFor small results, it is unlikely to be any faster than '(^)', quite possibly slower (though the difference shouldn't be large), and for exponents with few bits set, the same holds. But for exponents with many bits set, the speedup can be significant.Warning:~ No check for the negativity of the exponent is performed, a negative exponent is interpreted as a large positive exponent. A raw version of testBit for !." " Bas van Dijk 2013BSD3#Bas van Dijk <v.dijk.bas@gmail.com>None+N1An arbitrary-precision number represented using  0http://en.wikipedia.org/wiki/Scientific_notationscientific notation.#This type describes the set of all #s( which have a finite decimal expansion.A scientific number with  c and  e corresponds to the $ number: % c * 10 & e'The coefficient of a scientific number.[Note that this number is not necessarily normalized, i.e. it could contain trailing zeros.KScientific numbers are automatically normalized when pretty printed or in .Use  to do manual normalization.,The base-10 exponent of a scientific number.scientific c e: constructs a scientific number which corresponds to the $ number: % c * 10 & e.Like ', this function converts a ( to a @ but instead of diverging (i.e loop and consume all space) on  /https://en.wikipedia.org/wiki/Repeating_decimalrepeating decimals% it detects the repeating part, the repetend, and returns where it starts.æTo detect the repetition this function consumes space linear in the number of digits in the resulting scientific. In order to bound the space usage an optional limit can be specified. If the number of digits reaches this limit  Left (s, r) will be returned. Here s is the  constructed so far and r is the remaining (. toRational s + r yields the original (6If the limit is not reached or no limit was specified Right (s, mbRepetendIx) will be returned. Here s is the  without any repetition and  mbRepetendIxD specifies if and where in the fractional part the repetend begins. For example: DfromRationalRepetend Nothing (1 % 28) == Right (3.571428e-2, Just 2)'This represents the repeating decimal: 0.03571428571428571428...3 which is sometimes also unambiguously denoted as  0.03(571428)›. Here the repetend is enclosed in parentheses and starts at the 3rd digit (index 2) in the fractional part. Specifying a limit results in the following: AfromRationalRepetend (Just 4) (1 % 28) == Left (3.5e-2, 1 % 1400).You can expect the following property to hold. < forall (mbLimit :: Maybe Int) (r :: Rational). r == (case Å mbLimit r of Left (s, r') -> toRational s + r' Right (s, mbRepetendIx) -> case mbRepetendIx of Nothing -> toRational s Just repetendIx ->   s repetendIx)  Converts a  with a repetend^ (a repeating part in the fraction), which starts at the given index, into its corresponding (.-For example to convert the repeating decimal  0.03(571428) you would use: )toRationalRepetend 0.03571428 2 == 1 % 28Preconditions for toRationalRepetend s r: r >= 0 r < -(base10Exponent s)The formula to convert the  Scientific s$ with a repetend starting at index r is described in the paper:  Yhttp://fiziko.bureau42.com/teaching_tidbits/turning_repeating_decimals_into_fractions.pdf-turning_repeating_decimals_into_fractions.pdf and is defined as follows: ÿ (fromInteger nonRepetend + repetend % nines) / fromInteger (10^^r) where c = coefficient s e = base10Exponent s -- Size of the fractional part. f = (-e) -- Size of the repetend. n = f - r m = 10^^n (nonRepetend, repetend) = c `quotRem` m nines = m - 1  Also see: .)This function is used in the *Y methods to guard against computing a huge magnitude (-e) which could take up all space.€Think about parsing a scientific number from an untrusted string. An attacker could supply 1e-1000000000. Lets say we want to + that number to an ,). When we naively try to floor it using: 7floor = whenFloating $ c e -> fromInteger (c - magnitude (-e)) "We will compute the huge Integer: magnitude 1000000000I. This computation will quickly fill up all space and crash the program.Note that for large positive3 exponents there is no risk of a space-leak since . will compute:  fromInteger c * magnitude e :: awhere ab is the target type (Int in this example). So here the space usage is bounded by the target type.ÿ*For large negative exponents we check if the exponent is smaller than some limit (currently -324). In that case we know that the scientific number is really small (unless the coefficient has many digits) so we can immediately return -1 for negative scientific numbers or 0 for positive numbers.More precisely if dangerouslySmall c e returns / the scientific number s is guaranteed to be between: -0.1 > s < 0.1.qNote that we avoid computing the number of decimal digits in c (log10 c) if the exponent is not below the limit.0Precondition: the  s needs to be an integer: !base10Exponent (normalize s) >= 01The same limit as in GHC.Float.2 magnitude e == 10 ^ e  Convert a 3 (like a 4 or 5 ) into a  number.Note that this function uses 6, to compute the digits and exponent of the 3. number. Be aware that the algorithm used in 69 doesn't work as expected for some numbers, e.g. as the 4 1e23 is converted to 9.9999999999999991611392e22, and that value is shown as 9.999999999999999e22 rather than the shorter 1e23ÿ; the algorithm doesn't take the rounding direction for values exactly half-way between two adjacent representable values into account, so if you have a value with a short decimal representation exactly half-way between two adjacent representable values, like 5^23*2^e for eˆ close to 23, the algorithm doesn't know in which direction the short decimal representation would be rounded and computes more digits Safely convert a  number into a 3 (like a 4 or a 5).Note that this function uses 7 (' . 8G) internally but it guards against computing huge Integer magnitudes (10^e?) that could fill up all space and crash your program. If the  of the given r is too big or too small to be represented in the target type, Infinity or 0 will be returned respectively. Use  1 which explicitly handles this case by returning 9.Always prefer   over 7J when converting from scientific numbers coming from an untrusted source. Preciser version of   . If the  of the given b is too big or too small to be represented in the target type, Infinity or 0 will be returned as 9.  Convert a  to a bounded integer. If the given ; doesn't fit in the target representation, it will return :.EThis function also guards against computing huge Integer magnitudes (10^e7) that could fill up all space and crash your program.floatingOrInteger… determines if the scientific is floating point or integer. In case it's floating-point the scientific is converted to the desired 3 using  . Also see:  or .Return /( if the scientific is a floating point, ; otherwise. Also see: .Return /" if the scientific is an integer, ; otherwise. Also see: .Like < but provides rendering options. Similar to 6, toDecimalDigits takes a positive Q 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 /null $ takeWhile (==0) $ reverse [d1,d2,...,dn]fThe last property means that the coefficient will be normalized, i.e. doesn't contain trailing zeros.ENormalize a scientific number by dividing out powers of 10 from the  and incrementing the  each time.‚You should rarely have a need for this function since scientific numbers are automatically normalized when pretty-printed and in .=WARNING: > and ?H will diverge (i.e. loop and consume all space) when their outputs are  /https://en.wikipedia.org/wiki/Repeating_decimalrepeating decimals.' will diverge when the input () is a repeating decimal. Consider using T for these rationals which will detect the repetition and indicate where it starts.@WARNING: 8 needs to compute the  magnitude: 10^eU. If applied to a huge exponent this could fill up all space and crash your program!Avoid applying 8 (or 7A) to scientific numbers coming from an untrusted source and use  ; instead. The latter guards against excessive space usage./ABCOptional limit Repetend index)DE.01F2 G HIJKLMN#Number of decimal places to render.OPQR=@STUVWX   +ABC )DE.01F2 G HIJKLMNOPQR=@STUVWXNoneA 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.Like  but provides rendering options.#Number of decimal places to render.NoneA  ByteString 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.Like  but provides rendering options.#Number of decimal places to render.Y         !" !#$% &'() &*+,-./012013045016017018901:01;,<=01>?,<@ABC0DE,<F,<G0DH01I01J0KL0MN,<O0PQR01S01TUVVWXYZ[\]^_`abcdefghijklscien_1OnQq6NJ9k3LnQc0gkGZFNData.Scientific!Data.Text.Lazy.Builder.Scientific"Data.ByteString.Builder.ScientificGHC.Integer.Logarithms.CompatUtilsGHC.Integer.CompatMath.NumberTheory.Logarithmstext_5c7VCmRXJenGcMPs3kwpkI Data.Text.Lazy.Builder.RealFloatGenericFixedExponentFPFormat Scientific coefficientbase10Exponent scientificfromRationalRepetendtoRationalRepetendfromFloatDigits toRealFloattoBoundedRealFloattoBoundedIntegerfloatingOrInteger isFloating isIntegerformatScientifictoDecimalDigits normalizescientificBuilderformatScientificBuilder integer-gmpGHC.Integer.Logarithms wordLog2# integerLog2#i2droundToGHC.Integer.Type divInteger integerLog10' integerPowerIntegerhasBit#ghc-primGHC.PrimWord#powerbaseGHC.RealReal FractionalGHC.Num fromInteger^^ fromRationalRationaldangerouslySmallRealFracfloor GHC.TypesIntdiv whenFloatingTrue toIntegralmaxExpt magnitude GHC.Float RealFloatDoubleFloat floatToDigits realToFrac toRational Data.EitherLeftGHC.BaseNothingFalseGHC.Showshow$fFractionalScientificrecip/$fRealScientificSPlimit positivizeexpts10exponentLimits scientificP foldDigits isDecimalisSignisE fmtAsExponent fmtAsFixednormalizePositive$fShowScientific$fReadScientific$fRealFracScientific$fNumScientific$fOrdScientific$fEqScientific$fBinaryScientific$fHashableScientific$fNFDataScientific