úÎwArè     None"Only defined for positive inputs!  Power of an 3 by the left-to-right repeated squaring algorithm. G This needs two multiplications in each step while the right-to-left D algorithm needs only one multiplication for 0-bits, but here the I two factors always have approximately the same size, which on average ) gains a bit when the result is large. 8For small results, it is unlikely to be any faster than '(^)', quite 1 possibly slower (though the difference shouldn't be large), and for G exponents with few bits set, the same holds. But for exponents with 2 many bits set, the speedup can be significant. Warning:; No check for the negativity of the exponent is performed, D a negative exponent is interpreted as a large positive exponent. A raw version of testBit for . #Bas van Dijk <v.dijk.bas@gmail.com>None0An 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. GScientific numbers are automatically normalized when pretty printed or  in . Use  to do manual normalization. -The base-10 exponent of a scientific number. scientific c e2 constructs a scientific number which corresponds  to the  number:  c * 10   e. !This function is used in the " methods to guard against @ computing a huge magnitude (-e) which could take up all space. :Think about parsing a scientific number from an untrusted E string. An attacker could supply 1e-1000000000. Lets say we want to  # that number to an $". When we naively try to floor it  using:    floor = whenFloating $ c e ->  fromInteger (c % magnitude (-e)) "We will compute the huge Integer: magnitude 1000000000. This C computation will quickly fill up all space and crash the program. Note that for large positive! exponents there is no risk of a  space-leak since & will compute:   fromInteger c * magnitude e :: awhere a7 is the target type (Int in this example). So here the , space usage is bounded by the target type. AFor large negative exponents we check if the exponent is smaller A than some limit (currently -324). In that case we know that the D scientific number is really small (unless the coefficient has many A 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. ?Note that we avoid computing the number of decimal digits in c 3 (log10 c) if the exponent is not below the limit. (Precondition: the  s needs to be an integer:  !base10Exponent (normalize s) >= 0 ) The same limit as in GHC.Float. * magnitude e == 10 ^ e Convert a + (like a , or - ) into a   number. Note that this function uses . to compute the digits  and exponent of the +- number. Be aware that the algorithm used in  . doesn'-t work as expected for some numbers, e.g. as  the , 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 J between two adjacent representable values into account, so if you have a H 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 + (like a , or a  -). Note that this function uses / (0 . 1) E 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 2 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 2. Always prefer   over /! when converting from scientific * numbers coming from an untrusted source. Preciser version of   . If the  of the given  ? is too big or too small to be represented in the target type, # Infinity or 0 will be returned as 2.  Convert a  to a bounded integer.  If the given  doesn',t fit in the target representation, it will  return 3. EThis function also guards against computing huge Integer magnitudes (10^e) 6 that could fill up all space and crash your program. floatingOrInteger0 determines if the scientific is floating point  or integer. In case it'-s floating-point the scientific is converted  to the desired + using  .  Also see:   or . Return '( if the scientific is a floating point, 4 otherwise.  Also see:  . Return '" if the scientific is an integer, 4 otherwise.  Also see:  . Like 5! but provides rendering options.  Similar to ., toDecimalDigits takes a  non-negative * 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  2. x = 0.d1d2...dn * (10^^e)  3. 0 <= di <= 9  4. .null $ takeWhile (==0) $ reverse [d1,d2,...,dn] KThe last property means that the coefficient will be normalized, i.e. doesn't  contain trailing zeros. DNormalize a scientific number by dividing out powers of 10 from the   and incrementing the  each time. MYou should rarely have a need for this function since scientific numbers are 5 automatically normalized when pretty-printed and in . 6WARNING: 7 and 80 will diverge (i.e. loop and consume all space) 8 when their outputs have an infinite decimal expansion. 0 will  diverge when the input 9$ has an infinite decimal expansion. :WARNING: 1 needs to compute the  magnitude:  10^e=. If applied to a huge exponent this could fill up all space  and crash your program! Avoid applying 1 (or /) to scientific numbers ) coming from an untrusted source and use   instead. The . latter guards against excessive space usage. +;<=!>?&()@* A BCDEF$Number of decimal places to render. GHIJK6:LMNOP   ';<=!>?&()@* A BCDEFGHIJK6:LMNOPNoneA 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. Q&Unsafe conversion for decimal digits. $Number of decimal places to render. QRQRNoneA  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. S&Unsafe conversion for decimal digits. $Number of decimal places to render. STSTU      !"#$%&'(&')&*+&',-&'.&'/!01&'23!04567&89!0:!0;&8<&'=&'>&'?&@A&BC!0D&EFG&'H&'I&'JKLL MNOPQRSTUVWXYZ[\]^_`V`Vascientific-0.3.3.2Data.Scientific!Data.Text.Lazy.Builder.Scientific"Data.ByteString.Builder.ScientificMath.NumberTheory.Logarithms text-1.2.0.0 Data.Text.Lazy.Builder.RealFloatExponentFixedGenericFPFormat Scientific coefficientbase10Exponent scientificfromFloatDigits toRealFloattoBoundedRealFloattoBoundedIntegerfloatingOrInteger isFloating isIntegerformatScientifictoDecimalDigits normalizescientificBuilderformatScientificBuilder integerLog10' integerPower integer-gmpGHC.Integer.TypeIntegerhasBit#ghc-primGHC.PrimWord#powerisTrue#baseGHC.RealReal FractionalGHC.Num fromInteger^^dangerouslySmallRealFracfloor GHC.TypesIntdiv whenFloatingTrue toIntegralmaxExpt magnitude GHC.Float RealFloatDoubleFloat floatToDigits realToFrac fromRational toRational Data.EitherLeft Data.MaybeNothingFalseGHC.Showshow$fFractionalScientificrecip/Rational$fRealScientificSPlimit positivizeexpts10exponentLimits scientificP foldDigits isDecimalisSignisEroundTonormalizePositive$fShowScientific$fReadScientific$fRealFracScientific$fNumScientific$fOrdScientific$fEqScientific$fHashableScientific$fNFDataScientifici2d