long-decimal 0.00.21 → 0.00.22
Sign up to get free protection for your applications and to get access to all the features.
- data/README +23 -16
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/doc/classes/LongDecimal.html +343 -343
- data/doc/classes/LongDecimal.src/M000036.html +4 -4
- data/doc/classes/LongDecimal.src/M000037.html +4 -4
- data/doc/classes/LongDecimal.src/M000038.html +4 -4
- data/doc/classes/LongDecimal.src/M000039.html +4 -4
- data/doc/classes/LongDecimal.src/M000040.html +4 -6
- data/doc/classes/LongDecimal.src/M000041.html +4 -106
- data/doc/classes/LongDecimal.src/M000042.html +6 -21
- data/doc/classes/LongDecimal.src/M000043.html +105 -10
- data/doc/classes/LongDecimal.src/M000044.html +17 -23
- data/doc/classes/LongDecimal.src/M000045.html +10 -18
- data/doc/classes/LongDecimal.src/M000046.html +27 -4
- data/doc/classes/LongDecimal.src/M000047.html +17 -13
- data/doc/classes/LongDecimal.src/M000048.html +4 -28
- data/doc/classes/LongDecimal.src/M000049.html +15 -4
- data/doc/classes/LongDecimal.src/M000050.html +26 -6
- data/doc/classes/LongDecimal.src/M000051.html +4 -6
- data/doc/classes/LongDecimal.src/M000052.html +8 -4
- data/doc/classes/LongDecimal.src/M000053.html +6 -15
- data/doc/classes/LongDecimal.src/M000054.html +4 -7
- data/doc/classes/LongDecimal.src/M000055.html +15 -4
- data/doc/classes/LongDecimal.src/M000056.html +6 -14
- data/doc/classes/LongDecimal.src/M000057.html +4 -13
- data/doc/classes/LongDecimal.src/M000058.html +15 -4
- data/doc/classes/LongDecimal.src/M000059.html +13 -4
- data/doc/classes/LongDecimal.src/M000060.html +4 -4
- data/doc/classes/LongDecimal.src/M000062.html +4 -5
- data/doc/classes/LongDecimal.src/M000063.html +5 -4
- data/doc/classes/LongDecimal.src/M000064.html +5 -8
- data/doc/classes/LongDecimal.src/M000065.html +4 -9
- data/doc/classes/LongDecimal.src/M000066.html +6 -7
- data/doc/classes/LongDecimal.src/M000067.html +6 -6
- data/doc/classes/LongDecimal.src/M000068.html +9 -4
- data/doc/classes/LongDecimal.src/M000069.html +7 -13
- data/doc/classes/LongDecimal.src/M000070.html +4 -9
- data/doc/classes/LongDecimal.src/M000071.html +13 -7
- data/doc/classes/LongDecimal.src/M000072.html +7 -18
- data/doc/classes/LongDecimal.src/M000073.html +8 -7
- data/doc/classes/LongDecimal.src/M000074.html +20 -5
- data/doc/classes/LongDecimal.src/M000075.html +7 -8
- data/doc/classes/LongDecimal.src/M000076.html +5 -9
- data/doc/classes/LongDecimal.src/M000077.html +5 -5
- data/doc/classes/LongDecimal.src/M000078.html +9 -4
- data/doc/classes/LongDecimal.src/M000079.html +8 -6
- data/doc/classes/LongDecimal.src/M000080.html +4 -7
- data/doc/classes/LongDecimal.src/M000081.html +7 -4
- data/doc/classes/LongDecimal.src/M000082.html +7 -4
- data/doc/classes/LongDecimal.src/M000083.html +4 -9
- data/doc/classes/LongDecimal.src/M000084.html +4 -9
- data/doc/classes/LongDecimal.src/M000085.html +9 -5
- data/doc/classes/LongDecimal.src/M000086.html +7 -7
- data/doc/classes/LongDecimal.src/M000087.html +5 -4
- data/doc/classes/LongDecimal.src/M000088.html +9 -4
- data/doc/classes/LongDecimal.src/M000089.html +4 -4
- data/doc/classes/LongDecimal.src/M000090.html +4 -4
- data/doc/classes/LongDecimal.src/M000091.html +4 -59
- data/doc/classes/LongDecimal.src/M000092.html +4 -4
- data/doc/classes/LongDecimal.src/M000093.html +59 -4
- data/doc/classes/LongDecimal.src/M000094.html +4 -5
- data/doc/classes/LongDecimal.src/M000095.html +4 -4
- data/doc/classes/LongDecimal.src/M000098.html +5 -4
- data/doc/classes/LongDecimal.src/M000099.html +5 -4
- data/doc/classes/LongDecimal.src/M000100.html +4 -4
- data/doc/classes/LongDecimal.src/M000101.html +4 -4
- data/doc/classes/LongDecimalBase.html +53 -53
- data/doc/classes/LongDecimalBase.src/M000107.html +4 -4
- data/doc/classes/LongDecimalBase.src/M000108.html +4 -4
- data/doc/classes/LongDecimalBase.src/M000109.html +4 -4
- data/doc/classes/LongDecimalBase.src/M000110.html +4 -4
- data/doc/classes/LongDecimalBase.src/M000111.html +4 -5
- data/doc/classes/LongDecimalBase.src/M000112.html +9 -9
- data/doc/classes/LongDecimalBase.src/M000115.html +23 -0
- data/doc/classes/LongDecimalQuot.html +174 -133
- data/doc/classes/LongDecimalQuot.src/M000003.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000004.html +2 -1
- data/doc/classes/LongDecimalQuot.src/M000005.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000006.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000007.html +6 -5
- data/doc/classes/LongDecimalQuot.src/M000008.html +5 -4
- data/doc/classes/LongDecimalQuot.src/M000009.html +4 -4
- data/doc/classes/LongDecimalQuot.src/M000010.html +4 -4
- data/doc/classes/LongDecimalQuot.src/M000011.html +4 -4
- data/doc/classes/LongDecimalQuot.src/M000012.html +4 -4
- data/doc/classes/LongDecimalQuot.src/M000013.html +7 -4
- data/doc/classes/LongDecimalQuot.src/M000014.html +5 -8
- data/doc/classes/LongDecimalQuot.src/M000015.html +5 -9
- data/doc/classes/LongDecimalQuot.src/M000016.html +6 -7
- data/doc/classes/LongDecimalQuot.src/M000017.html +4 -4
- data/doc/classes/LongDecimalQuot.src/M000018.html +4 -4
- data/doc/classes/LongDecimalQuot.src/M000019.html +6 -18
- data/doc/classes/LongDecimalQuot.src/M000020.html +8 -7
- data/doc/classes/LongDecimalQuot.src/M000021.html +21 -5
- data/doc/classes/LongDecimalQuot.src/M000022.html +8 -4
- data/doc/classes/LongDecimalQuot.src/M000023.html +5 -96
- data/doc/classes/LongDecimalQuot.src/M000024.html +4 -38
- data/doc/classes/LongDecimalQuot.src/M000025.html +96 -4
- data/doc/classes/LongDecimalQuot.src/M000026.html +38 -4
- data/doc/classes/LongDecimalQuot.src/M000027.html +4 -4
- data/doc/classes/LongDecimalQuot.src/M000028.html +4 -4
- data/doc/classes/LongDecimalQuot.src/M000029.html +4 -4
- data/doc/classes/LongDecimalRoundingMode/RoundingModeClass.html +10 -10
- data/doc/classes/LongDecimalRoundingMode/RoundingModeClass.src/M000148.html +22 -0
- data/doc/classes/LongDecimalRoundingMode/RoundingModeClass.src/M000149.html +18 -0
- data/doc/classes/LongMath.html +159 -161
- data/doc/classes/LongMath.src/M000118.html +5 -4
- data/doc/classes/LongMath.src/M000119.html +4 -5
- data/doc/classes/LongMath.src/M000120.html +4 -4
- data/doc/classes/LongMath.src/M000121.html +5 -18
- data/doc/classes/LongMath.src/M000122.html +4 -18
- data/doc/classes/LongMath.src/M000123.html +18 -5
- data/doc/classes/LongMath.src/M000124.html +16 -27
- data/doc/classes/LongMath.src/M000125.html +4 -4
- data/doc/classes/LongMath.src/M000126.html +17 -45
- data/doc/classes/LongMath.src/M000127.html +5 -21
- data/doc/classes/LongMath.src/M000128.html +50 -29
- data/doc/classes/LongMath.src/M000129.html +21 -6
- data/doc/classes/LongMath.src/M000130.html +31 -28
- data/doc/classes/LongMath.src/M000131.html +6 -48
- data/doc/classes/LongMath.src/M000132.html +33 -8
- data/doc/classes/LongMath.src/M000133.html +51 -4
- data/doc/classes/LongMath.src/M000134.html +7 -4
- data/doc/classes/LongMath.src/M000135.html +4 -64
- data/doc/classes/LongMath.src/M000136.html +4 -43
- data/doc/classes/LongMath.src/M000137.html +64 -4
- data/doc/classes/LongMath.src/M000138.html +43 -4
- data/doc/classes/LongMath.src/M000139.html +4 -7
- data/doc/classes/LongMath.src/M000140.html +4 -20
- data/doc/classes/LongMath.src/M000141.html +4 -18
- data/doc/classes/LongMath.src/M000142.html +11 -34
- data/doc/classes/LongMath.src/M000143.html +13 -253
- data/doc/classes/LongMath.src/M000144.html +40 -16
- data/doc/classes/LongMath.src/M000145.html +227 -0
- data/doc/classes/LongMath.src/M000146.html +33 -0
- data/doc/classes/LongMath/CacheKey.html +6 -6
- data/doc/classes/LongMath/CacheKey.src/M000147.html +36 -0
- data/doc/classes/Numeric.html +10 -10
- data/doc/classes/Numeric.src/M000103.html +18 -0
- data/doc/classes/Rational.html +5 -5
- data/doc/classes/Rational.src/M000104.html +23 -0
- data/doc/created.rid +1 -1
- data/doc/files/lib/long-decimal_rb.src/M000001.html +1 -1
- data/doc/files/lib/long-decimal_rb.src/M000002.html +1 -1
- data/doc/fr_method_index.html +145 -143
- data/lib/long-decimal.rb +52 -71
- data/test/testlongdecimal.rb +218 -449
- data/test/testlongdeclib.rb +485 -0
- data/test/testrandom.rb +75 -0
- data/version.rb +1 -1
- metadata +12 -3
- data/doc/files/lib/long-decimal_rb.html +0 -189
@@ -5,48 +5,14 @@
|
|
5
5
|
|
6
6
|
<html>
|
7
7
|
<head>
|
8
|
-
<title>
|
8
|
+
<title>abs (LongDecimalQuot)</title>
|
9
9
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
10
|
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">
|
15
|
-
|
16
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">LongDecimal</span> <span class="ruby-keyword kw">then</span>
|
17
|
-
<span class="ruby-comment cmt"># convert LongDecimal to LongDecimalQuot</span>
|
18
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-constant">LongDecimalQuot</span>(<span class="ruby-identifier">other</span>.<span class="ruby-identifier">to_r</span>, <span class="ruby-identifier">other</span>.<span class="ruby-identifier">scale</span>), <span class="ruby-keyword kw">self</span>
|
19
|
-
|
20
|
-
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">LongDecimalQuot</span> <span class="ruby-keyword kw">then</span>
|
21
|
-
<span class="ruby-comment cmt"># nothing to convert, if both are already LongDecimalQuot</span>
|
22
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">other</span>, <span class="ruby-keyword kw">self</span>
|
23
|
-
|
24
|
-
<span class="ruby-keyword kw">elsif</span> (<span class="ruby-identifier">other</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">Rational</span>) <span class="ruby-operator">||</span> (<span class="ruby-identifier">other</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">Integer</span>) <span class="ruby-keyword kw">then</span>
|
25
|
-
<span class="ruby-comment cmt"># convert Rational or Integer to LongDecimalQuot. The only</span>
|
26
|
-
<span class="ruby-comment cmt"># missing part, scale, is just taken from self</span>
|
27
|
-
<span class="ruby-identifier">s</span> = <span class="ruby-identifier">scale</span>
|
28
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-constant">LongDecimalQuot</span>(<span class="ruby-identifier">other</span>, <span class="ruby-identifier">s</span>), <span class="ruby-keyword kw">self</span>
|
29
|
-
|
30
|
-
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">Float</span> <span class="ruby-keyword kw">then</span>
|
31
|
-
<span class="ruby-comment cmt"># convert Float to LongDecimalQuot via LongDecimal</span>
|
32
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-constant">LongDecimalQuot</span>(<span class="ruby-identifier">other</span>.<span class="ruby-identifier">to_ld</span>.<span class="ruby-identifier">to_r</span>, <span class="ruby-identifier">scale</span>), <span class="ruby-keyword kw">self</span>
|
33
|
-
|
34
|
-
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">BigDecimal</span> <span class="ruby-keyword kw">then</span>
|
35
|
-
<span class="ruby-comment cmt"># for BigDecimal, convert self to BigDecimal as well</span>
|
36
|
-
<span class="ruby-identifier">s</span>, <span class="ruby-identifier">o</span> = <span class="ruby-identifier">other</span>.<span class="ruby-identifier">coerce</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_bd</span>)
|
37
|
-
|
38
|
-
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">Numeric</span> <span class="ruby-keyword kw">then</span>
|
39
|
-
<span class="ruby-comment cmt"># for all other numeric types convert self to Float. This may</span>
|
40
|
-
<span class="ruby-comment cmt"># not work, if numerator and denominator have too many digits to</span>
|
41
|
-
<span class="ruby-comment cmt"># be expressed as Float and it may cause loss of information.</span>
|
42
|
-
<span class="ruby-identifier">s</span>, <span class="ruby-identifier">o</span> = <span class="ruby-identifier">other</span>.<span class="ruby-identifier">coerce</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_f</span>)
|
43
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">o</span>, <span class="ruby-identifier">s</span>
|
44
|
-
|
45
|
-
<span class="ruby-keyword kw">else</span>
|
46
|
-
<span class="ruby-comment cmt"># non-numeric types do not work at all</span>
|
47
|
-
<span class="ruby-identifier">raise</span> <span class="ruby-constant">TypeError</span>, <span class="ruby-node">"unsupported type #{other.inspect} for coerce of LongDecimalQuot"</span>
|
48
|
-
<span class="ruby-keyword kw">end</span>
|
49
|
-
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line 1486</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">abs</span>
|
15
|
+
<span class="ruby-constant">LongDecimalQuot</span>(<span class="ruby-identifier">rat</span>.<span class="ruby-identifier">abs</span>, <span class="ruby-identifier">scale</span>)
|
50
16
|
<span class="ruby-keyword kw">end</span></pre>
|
51
17
|
</body>
|
52
18
|
</html>
|
@@ -5,14 +5,106 @@
|
|
5
5
|
|
6
6
|
<html>
|
7
7
|
<head>
|
8
|
-
<title
|
8
|
+
<title>round_to_scale (LongDecimalQuot)</title>
|
9
9
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
10
|
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-
|
15
|
-
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line 1500</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">round_to_scale</span>(<span class="ruby-identifier">new_scale</span> = <span class="ruby-ivar">@scale</span>, <span class="ruby-identifier">mode</span> = <span class="ruby-constant">ROUND_UNNECESSARY</span>)
|
15
|
+
|
16
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">TypeError</span>, <span class="ruby-node">"new_scale #{new_scale.inspect} must be integer"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">new_scale</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">Integer</span>
|
17
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">TypeError</span>, <span class="ruby-node">"new_scale #{new_scale.inspect} must be >= 0"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">new_scale</span> <span class="ruby-operator">>=</span> <span class="ruby-value">0</span>
|
18
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">TypeError</span>, <span class="ruby-node">"mode #{mode.inspect} must be legal rounding mode"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">mode</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">RoundingModeClass</span>
|
19
|
+
|
20
|
+
<span class="ruby-identifier">sign_quot</span> = <span class="ruby-identifier">numerator</span> <span class="ruby-operator"><=></span> <span class="ruby-value">0</span>
|
21
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">sign_quot</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span> <span class="ruby-keyword kw">then</span>
|
22
|
+
<span class="ruby-comment cmt"># finish zero without long calculations at once</span>
|
23
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-constant">LongDecimal</span>(<span class="ruby-value">0</span>, <span class="ruby-identifier">new_scale</span>)
|
24
|
+
<span class="ruby-keyword kw">end</span>
|
25
|
+
|
26
|
+
<span class="ruby-identifier">factor</span> = <span class="ruby-value">10</span><span class="ruby-operator">**</span><span class="ruby-identifier">new_scale</span>
|
27
|
+
<span class="ruby-identifier">prod</span> = <span class="ruby-identifier">numerator</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">factor</span>
|
28
|
+
<span class="ruby-identifier">divisor</span> = <span class="ruby-identifier">denominator</span>
|
29
|
+
<span class="ruby-identifier">quot</span>, <span class="ruby-identifier">rem</span> = <span class="ruby-identifier">prod</span>.<span class="ruby-identifier">divmod</span>(<span class="ruby-identifier">divisor</span>)
|
30
|
+
<span class="ruby-identifier">sign_rem</span> = <span class="ruby-identifier">rem</span> <span class="ruby-operator"><=></span> <span class="ruby-value">0</span>
|
31
|
+
<span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">sign_rem</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>)
|
32
|
+
<span class="ruby-comment cmt"># if self can be expressed without loss as LongDecimal with</span>
|
33
|
+
<span class="ruby-comment cmt"># new_scale digits after the decimal point, just do it.</span>
|
34
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-constant">LongDecimal</span>(<span class="ruby-identifier">quot</span>, <span class="ruby-identifier">new_scale</span>)
|
35
|
+
<span class="ruby-keyword kw">end</span>
|
36
|
+
|
37
|
+
<span class="ruby-comment cmt"># we do not expect negative signs of remainder. To make sure that</span>
|
38
|
+
<span class="ruby-comment cmt"># this does not cause problems in further code, we just throw an</span>
|
39
|
+
<span class="ruby-comment cmt"># exception. This should never happen (and did not happen during</span>
|
40
|
+
<span class="ruby-comment cmt"># testing).</span>
|
41
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">Error</span>, <span class="ruby-node">"signs do not match self=#{self.to_s} f=#{factor} prod=#{prod} divisor=#{divisor} quot=#{quot} rem=#{rem}"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">sign_rem</span> <span class="ruby-operator"><=</span> <span class="ruby-value">0</span>
|
42
|
+
|
43
|
+
<span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">sign_quot</span> <span class="ruby-operator"><</span> <span class="ruby-value">0</span>) <span class="ruby-keyword kw">then</span>
|
44
|
+
<span class="ruby-comment cmt"># handle negative sign of self</span>
|
45
|
+
<span class="ruby-identifier">rem</span> <span class="ruby-operator">-=</span> <span class="ruby-identifier">divisor</span>
|
46
|
+
<span class="ruby-identifier">quot</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
|
47
|
+
<span class="ruby-identifier">sign_rem</span> = <span class="ruby-identifier">rem</span> <span class="ruby-operator"><=></span> <span class="ruby-value">0</span>
|
48
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">Error</span>, <span class="ruby-node">"signs do not match self=#{self.to_s} f=#{factor} prod=#{prod} divisor=#{divisor} quot=#{quot} rem=#{rem}"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">sign_rem</span> <span class="ruby-operator">>=</span> <span class="ruby-value">0</span>
|
49
|
+
<span class="ruby-keyword kw">end</span>
|
50
|
+
|
51
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">mode</span> <span class="ruby-operator">==</span> <span class="ruby-constant">ROUND_UNNECESSARY</span> <span class="ruby-keyword kw">then</span>
|
52
|
+
<span class="ruby-comment cmt"># this mode means that rounding should not be necessary. But</span>
|
53
|
+
<span class="ruby-comment cmt"># the case that no rounding is needed, has already been covered</span>
|
54
|
+
<span class="ruby-comment cmt"># above, so it is an error, if this mode is required and the</span>
|
55
|
+
<span class="ruby-comment cmt"># result could not be returned above.</span>
|
56
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">"mode ROUND_UNNECESSARY not applicable, remainder #{rem.to_s} is not zero"</span>
|
57
|
+
<span class="ruby-keyword kw">end</span>
|
58
|
+
|
59
|
+
<span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">mode</span> <span class="ruby-operator">==</span> <span class="ruby-constant">ROUND_CEILING</span>)
|
60
|
+
<span class="ruby-comment cmt"># ROUND_CEILING goes to the closest allowed number >= self, even</span>
|
61
|
+
<span class="ruby-comment cmt"># for negative numbers. Since sign is handled separately, it is</span>
|
62
|
+
<span class="ruby-comment cmt"># more conveniant to use ROUND_UP or ROUND_DOWN depending on the</span>
|
63
|
+
<span class="ruby-comment cmt"># sign.</span>
|
64
|
+
<span class="ruby-identifier">mode</span> = (<span class="ruby-identifier">sign_quot</span> <span class="ruby-operator">></span> <span class="ruby-value">0</span>) <span class="ruby-operator">?</span> <span class="ruby-constant">ROUND_UP</span> <span class="ruby-operator">:</span> <span class="ruby-constant">ROUND_DOWN</span>
|
65
|
+
|
66
|
+
<span class="ruby-keyword kw">elsif</span> (<span class="ruby-identifier">mode</span> <span class="ruby-operator">==</span> <span class="ruby-constant">ROUND_FLOOR</span>)
|
67
|
+
<span class="ruby-comment cmt"># ROUND_FLOOR goes to the closest allowed number <= self, even</span>
|
68
|
+
<span class="ruby-comment cmt"># for negative numbers. Since sign is handled separately, it is</span>
|
69
|
+
<span class="ruby-comment cmt"># more conveniant to use ROUND_UP or ROUND_DOWN depending on the</span>
|
70
|
+
<span class="ruby-comment cmt"># sign.</span>
|
71
|
+
<span class="ruby-identifier">mode</span> = (<span class="ruby-identifier">sign_quot</span> <span class="ruby-operator"><</span> <span class="ruby-value">0</span>) <span class="ruby-operator">?</span> <span class="ruby-constant">ROUND_UP</span> <span class="ruby-operator">:</span> <span class="ruby-constant">ROUND_DOWN</span>
|
72
|
+
|
73
|
+
<span class="ruby-keyword kw">else</span>
|
74
|
+
<span class="ruby-comment cmt"># handle the ROUND_HALF_... stuff and find the adequate ROUND_UP</span>
|
75
|
+
<span class="ruby-comment cmt"># or ROUND_DOWN to use</span>
|
76
|
+
<span class="ruby-identifier">abs_rem</span> = <span class="ruby-identifier">rem</span>.<span class="ruby-identifier">abs</span>
|
77
|
+
<span class="ruby-identifier">half</span> = (<span class="ruby-identifier">abs_rem</span> <span class="ruby-operator"><<</span> <span class="ruby-value">1</span>) <span class="ruby-operator"><=></span> <span class="ruby-identifier">denominator</span>
|
78
|
+
<span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">mode</span> <span class="ruby-operator">==</span> <span class="ruby-constant">ROUND_HALF_UP</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">mode</span> <span class="ruby-operator">==</span> <span class="ruby-constant">ROUND_HALF_DOWN</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">mode</span> <span class="ruby-operator">==</span> <span class="ruby-constant">ROUND_HALF_EVEN</span>) <span class="ruby-keyword kw">then</span>
|
79
|
+
<span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">half</span> <span class="ruby-operator"><</span> <span class="ruby-value">0</span>) <span class="ruby-keyword kw">then</span>
|
80
|
+
<span class="ruby-identifier">mode</span> = <span class="ruby-constant">ROUND_DOWN</span>
|
81
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">half</span> <span class="ruby-operator">></span> <span class="ruby-value">0</span> <span class="ruby-keyword kw">then</span>
|
82
|
+
<span class="ruby-identifier">mode</span> = <span class="ruby-constant">ROUND_UP</span>
|
83
|
+
<span class="ruby-keyword kw">else</span>
|
84
|
+
<span class="ruby-comment cmt"># half == 0</span>
|
85
|
+
<span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">mode</span> <span class="ruby-operator">==</span> <span class="ruby-constant">ROUND_HALF_UP</span>) <span class="ruby-keyword kw">then</span>
|
86
|
+
<span class="ruby-identifier">mode</span> = <span class="ruby-constant">ROUND_UP</span>
|
87
|
+
<span class="ruby-keyword kw">elsif</span> (<span class="ruby-identifier">mode</span> <span class="ruby-operator">==</span> <span class="ruby-constant">ROUND_HALF_DOWN</span>) <span class="ruby-keyword kw">then</span>
|
88
|
+
<span class="ruby-identifier">mode</span> = <span class="ruby-constant">ROUND_DOWN</span>
|
89
|
+
<span class="ruby-keyword kw">else</span>
|
90
|
+
<span class="ruby-comment cmt"># mode == ROUND_HALF_EVEN</span>
|
91
|
+
<span class="ruby-identifier">mode</span> = (<span class="ruby-identifier">quot</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">==</span> <span class="ruby-value">1</span> <span class="ruby-operator">?</span> <span class="ruby-constant">ROUND_UP</span> <span class="ruby-operator">:</span> <span class="ruby-constant">ROUND_DOWN</span>)
|
92
|
+
<span class="ruby-keyword kw">end</span>
|
93
|
+
<span class="ruby-keyword kw">end</span>
|
94
|
+
<span class="ruby-keyword kw">end</span>
|
95
|
+
<span class="ruby-keyword kw">end</span>
|
96
|
+
|
97
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">mode</span> <span class="ruby-operator">==</span> <span class="ruby-constant">ROUND_UP</span>
|
98
|
+
<span class="ruby-comment cmt"># since the case where we can express the result exactly without</span>
|
99
|
+
<span class="ruby-comment cmt"># loss has already been handled above, ROUND_UP can be handled</span>
|
100
|
+
<span class="ruby-comment cmt"># correctly by adding one unit.</span>
|
101
|
+
<span class="ruby-identifier">quot</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">sign_quot</span>
|
102
|
+
<span class="ruby-keyword kw">end</span>
|
103
|
+
|
104
|
+
<span class="ruby-comment cmt"># put together result</span>
|
105
|
+
<span class="ruby-identifier">new_int_val</span> = <span class="ruby-identifier">quot</span>
|
106
|
+
<span class="ruby-constant">LongDecimal</span>(<span class="ruby-identifier">new_int_val</span>, <span class="ruby-identifier">new_scale</span>)
|
107
|
+
|
16
108
|
<span class="ruby-keyword kw">end</span></pre>
|
17
109
|
</body>
|
18
110
|
</html>
|
@@ -5,14 +5,48 @@
|
|
5
5
|
|
6
6
|
<html>
|
7
7
|
<head>
|
8
|
-
<title>
|
8
|
+
<title>coerce (LongDecimalQuot)</title>
|
9
9
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
10
|
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">
|
15
|
-
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line 1605</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">coerce</span>(<span class="ruby-identifier">other</span>)
|
15
|
+
|
16
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">LongDecimal</span> <span class="ruby-keyword kw">then</span>
|
17
|
+
<span class="ruby-comment cmt"># convert LongDecimal to LongDecimalQuot</span>
|
18
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-constant">LongDecimalQuot</span>(<span class="ruby-identifier">other</span>.<span class="ruby-identifier">to_r</span>, <span class="ruby-identifier">other</span>.<span class="ruby-identifier">scale</span>), <span class="ruby-keyword kw">self</span>
|
19
|
+
|
20
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">LongDecimalQuot</span> <span class="ruby-keyword kw">then</span>
|
21
|
+
<span class="ruby-comment cmt"># nothing to convert, if both are already LongDecimalQuot</span>
|
22
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">other</span>, <span class="ruby-keyword kw">self</span>
|
23
|
+
|
24
|
+
<span class="ruby-keyword kw">elsif</span> (<span class="ruby-identifier">other</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">Rational</span>) <span class="ruby-operator">||</span> (<span class="ruby-identifier">other</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">Integer</span>) <span class="ruby-keyword kw">then</span>
|
25
|
+
<span class="ruby-comment cmt"># convert Rational or Integer to LongDecimalQuot. The only</span>
|
26
|
+
<span class="ruby-comment cmt"># missing part, scale, is just taken from self</span>
|
27
|
+
<span class="ruby-identifier">s</span> = <span class="ruby-identifier">scale</span>
|
28
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-constant">LongDecimalQuot</span>(<span class="ruby-identifier">other</span>, <span class="ruby-identifier">s</span>), <span class="ruby-keyword kw">self</span>
|
29
|
+
|
30
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">Float</span> <span class="ruby-keyword kw">then</span>
|
31
|
+
<span class="ruby-comment cmt"># convert Float to LongDecimalQuot via LongDecimal</span>
|
32
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-constant">LongDecimalQuot</span>(<span class="ruby-identifier">other</span>.<span class="ruby-identifier">to_ld</span>.<span class="ruby-identifier">to_r</span>, <span class="ruby-identifier">scale</span>), <span class="ruby-keyword kw">self</span>
|
33
|
+
|
34
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">BigDecimal</span> <span class="ruby-keyword kw">then</span>
|
35
|
+
<span class="ruby-comment cmt"># for BigDecimal, convert self to BigDecimal as well</span>
|
36
|
+
<span class="ruby-identifier">s</span>, <span class="ruby-identifier">o</span> = <span class="ruby-identifier">other</span>.<span class="ruby-identifier">coerce</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_bd</span>)
|
37
|
+
|
38
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">Numeric</span> <span class="ruby-keyword kw">then</span>
|
39
|
+
<span class="ruby-comment cmt"># for all other numeric types convert self to Float. This may</span>
|
40
|
+
<span class="ruby-comment cmt"># not work, if numerator and denominator have too many digits to</span>
|
41
|
+
<span class="ruby-comment cmt"># be expressed as Float and it may cause loss of information.</span>
|
42
|
+
<span class="ruby-identifier">s</span>, <span class="ruby-identifier">o</span> = <span class="ruby-identifier">other</span>.<span class="ruby-identifier">coerce</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_f</span>)
|
43
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">o</span>, <span class="ruby-identifier">s</span>
|
44
|
+
|
45
|
+
<span class="ruby-keyword kw">else</span>
|
46
|
+
<span class="ruby-comment cmt"># non-numeric types do not work at all</span>
|
47
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">TypeError</span>, <span class="ruby-node">"unsupported type #{other.inspect} for coerce of LongDecimalQuot"</span>
|
48
|
+
<span class="ruby-keyword kw">end</span>
|
49
|
+
|
16
50
|
<span class="ruby-keyword kw">end</span></pre>
|
17
51
|
</body>
|
18
52
|
</html>
|
@@ -5,14 +5,14 @@
|
|
5
5
|
|
6
6
|
<html>
|
7
7
|
<head>
|
8
|
-
<title
|
8
|
+
<title>== (LongDecimalQuot)</title>
|
9
9
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
10
|
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">
|
15
|
-
(<span class="ruby-
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line 1653</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-operator">==</span>(<span class="ruby-identifier">other</span>)
|
15
|
+
(<span class="ruby-identifier">other</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">LongDecimalQuot</span>) <span class="ruby-operator">&&</span> (<span class="ruby-keyword kw">self</span> <span class="ruby-operator"><=></span> <span class="ruby-identifier">other</span>) <span class="ruby-operator">==</span> <span class="ruby-value">0</span> <span class="ruby-operator">&&</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">scale</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">scale</span>
|
16
16
|
<span class="ruby-keyword kw">end</span></pre>
|
17
17
|
</body>
|
18
18
|
</html>
|
@@ -5,14 +5,14 @@
|
|
5
5
|
|
6
6
|
<html>
|
7
7
|
<head>
|
8
|
-
<title>
|
8
|
+
<title>zero? (LongDecimalQuot)</title>
|
9
9
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
10
|
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">
|
15
|
-
<span class="ruby-
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line 1661</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">zero?</span>
|
15
|
+
<span class="ruby-ivar">@rat</span>.<span class="ruby-identifier">zero?</span>
|
16
16
|
<span class="ruby-keyword kw">end</span></pre>
|
17
17
|
</body>
|
18
18
|
</html>
|
@@ -5,14 +5,14 @@
|
|
5
5
|
|
6
6
|
<html>
|
7
7
|
<head>
|
8
|
-
<title>
|
8
|
+
<title>one? (LongDecimalQuot)</title>
|
9
9
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
10
|
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">
|
15
|
-
<span class="ruby-
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line 1669</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">one?</span>
|
15
|
+
(<span class="ruby-ivar">@rat</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>)
|
16
16
|
<span class="ruby-keyword kw">end</span></pre>
|
17
17
|
</body>
|
18
18
|
</html>
|
@@ -101,8 +101,8 @@ by <a href="../LongDecimal.html">LongDecimal</a>
|
|
101
101
|
<h3 class="section-bar">Methods</h3>
|
102
102
|
|
103
103
|
<div class="name-list">
|
104
|
-
<a href="#
|
105
|
-
<a href="#
|
104
|
+
<a href="#M000150"><=></a>
|
105
|
+
<a href="#M000151">hash</a>
|
106
106
|
</div>
|
107
107
|
</div>
|
108
108
|
|
@@ -131,12 +131,12 @@ by <a href="../LongDecimal.html">LongDecimal</a>
|
|
131
131
|
<div id="methods">
|
132
132
|
<h3 class="section-bar">Public Instance methods</h3>
|
133
133
|
|
134
|
-
<div id="method-
|
135
|
-
<a name="
|
134
|
+
<div id="method-M000150" class="method-detail">
|
135
|
+
<a name="M000150"></a>
|
136
136
|
|
137
137
|
<div class="method-heading">
|
138
|
-
<a href="RoundingModeClass.src/
|
139
|
-
onclick="popupCode('RoundingModeClass.src/
|
138
|
+
<a href="RoundingModeClass.src/M000150.html" target="Code" class="method-signature"
|
139
|
+
onclick="popupCode('RoundingModeClass.src/M000150.html');return false;">
|
140
140
|
<span class="method-name"><=></span><span class="method-args">(o)</span>
|
141
141
|
</a>
|
142
142
|
</div>
|
@@ -148,12 +148,12 @@ introduce some ordering for rounding modes
|
|
148
148
|
</div>
|
149
149
|
</div>
|
150
150
|
|
151
|
-
<div id="method-
|
152
|
-
<a name="
|
151
|
+
<div id="method-M000151" class="method-detail">
|
152
|
+
<a name="M000151"></a>
|
153
153
|
|
154
154
|
<div class="method-heading">
|
155
|
-
<a href="RoundingModeClass.src/
|
156
|
-
onclick="popupCode('RoundingModeClass.src/
|
155
|
+
<a href="RoundingModeClass.src/M000151.html" target="Code" class="method-signature"
|
156
|
+
onclick="popupCode('RoundingModeClass.src/M000151.html');return false;">
|
157
157
|
<span class="method-name">hash</span><span class="method-args">()</span>
|
158
158
|
</a>
|
159
159
|
</div>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title><=> (LongDecimalRoundingMode::RoundingModeClass)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line 32</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-operator"><=></span>(<span class="ruby-identifier">o</span>)
|
15
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">respond_to?</span><span class="ruby-identifier">:num</span>
|
16
|
+
<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">num</span> <span class="ruby-operator"><=></span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">num</span>
|
17
|
+
<span class="ruby-keyword kw">else</span>
|
18
|
+
<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">num</span> <span class="ruby-operator"><=></span> <span class="ruby-identifier">o</span>
|
19
|
+
<span class="ruby-keyword kw">end</span>
|
20
|
+
<span class="ruby-keyword kw">end</span></pre>
|
21
|
+
</body>
|
22
|
+
</html>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>hash (LongDecimalRoundingMode::RoundingModeClass)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line 40</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">hash</span>
|
15
|
+
<span class="ruby-identifier">num</span>
|
16
|
+
<span class="ruby-keyword kw">end</span></pre>
|
17
|
+
</body>
|
18
|
+
</html>
|
data/doc/classes/LongMath.html
CHANGED
@@ -101,37 +101,37 @@ href="LongDecimal.html">LongDecimal</a> instead of Float.
|
|
101
101
|
<h3 class="section-bar">Methods</h3>
|
102
102
|
|
103
103
|
<div class="name-list">
|
104
|
-
<a href="#
|
105
|
-
<a href="#
|
106
|
-
<a href="#
|
107
|
-
<a href="#
|
108
|
-
<a href="#
|
109
|
-
<a href="#
|
110
|
-
<a href="#
|
111
|
-
<a href="#
|
112
|
-
<a href="#
|
113
|
-
<a href="#
|
114
|
-
<a href="#
|
115
|
-
<a href="#
|
116
|
-
<a href="#
|
117
|
-
<a href="#
|
118
|
-
<a href="#
|
119
|
-
<a href="#
|
120
|
-
<a href="#
|
121
|
-
<a href="#
|
122
|
-
<a href="#
|
123
|
-
<a href="#
|
124
|
-
<a href="#
|
125
|
-
<a href="#
|
126
|
-
<a href="#
|
127
|
-
<a href="#
|
128
|
-
<a href="#
|
129
|
-
<a href="#
|
130
|
-
<a href="#
|
131
|
-
<a href="#
|
132
|
-
<a href="#
|
133
|
-
<a href="#
|
134
|
-
<a href="#
|
104
|
+
<a href="#M000146">calc_iprec_for_power</a>
|
105
|
+
<a href="#M000119">check_is_int</a>
|
106
|
+
<a href="#M000120">check_is_ld</a>
|
107
|
+
<a href="#M000122">check_is_mode</a>
|
108
|
+
<a href="#M000121">check_is_prec</a>
|
109
|
+
<a href="#M000118">check_word_len</a>
|
110
|
+
<a href="#M000134">exp</a>
|
111
|
+
<a href="#M000136">exp10</a>
|
112
|
+
<a href="#M000135">exp2</a>
|
113
|
+
<a href="#M000137">exp_internal</a>
|
114
|
+
<a href="#M000138">exp_raw</a>
|
115
|
+
<a href="#M000129">gcd_with_high_power</a>
|
116
|
+
<a href="#M000132">int_digits10</a>
|
117
|
+
<a href="#M000141">log</a>
|
118
|
+
<a href="#M000142">log10</a>
|
119
|
+
<a href="#M000143">log2</a>
|
120
|
+
<a href="#M000144">log_internal</a>
|
121
|
+
<a href="#M000145">log_raw</a>
|
122
|
+
<a href="#M000124">merge_from_words</a>
|
123
|
+
<a href="#M000131">multiplicity_of_10</a>
|
124
|
+
<a href="#M000130">multiplicity_of_factor</a>
|
125
|
+
<a href="#M000133">pi</a>
|
126
|
+
<a href="#M000147">power</a>
|
127
|
+
<a href="#M000148">power_internal</a>
|
128
|
+
<a href="#M000123">split_to_words</a>
|
129
|
+
<a href="#M000139">sqrt</a>
|
130
|
+
<a href="#M000140">sqrt_with_remainder</a>
|
131
|
+
<a href="#M000125">sqrtb</a>
|
132
|
+
<a href="#M000126">sqrtb_with_remainder</a>
|
133
|
+
<a href="#M000127">sqrtw</a>
|
134
|
+
<a href="#M000128">sqrtw_with_remainder</a>
|
135
135
|
</div>
|
136
136
|
</div>
|
137
137
|
|
@@ -199,12 +199,12 @@ href="LongDecimal.html">LongDecimal</a> instead of Float.
|
|
199
199
|
<div id="methods">
|
200
200
|
<h3 class="section-bar">Public Class methods</h3>
|
201
201
|
|
202
|
-
<div id="method-
|
203
|
-
<a name="
|
202
|
+
<div id="method-M000146" class="method-detail">
|
203
|
+
<a name="M000146"></a>
|
204
204
|
|
205
205
|
<div class="method-heading">
|
206
|
-
<a href="LongMath.src/
|
207
|
-
onclick="popupCode('LongMath.src/
|
206
|
+
<a href="LongMath.src/M000146.html" target="Code" class="method-signature"
|
207
|
+
onclick="popupCode('LongMath.src/M000146.html');return false;">
|
208
208
|
<span class="method-name">calc_iprec_for_power</span><span class="method-args">(x, y, prec)</span>
|
209
209
|
</a>
|
210
210
|
</div>
|
@@ -216,12 +216,12 @@ internal helper method for calculating the internal precision for power
|
|
216
216
|
</div>
|
217
217
|
</div>
|
218
218
|
|
219
|
-
<div id="method-
|
220
|
-
<a name="
|
219
|
+
<div id="method-M000119" class="method-detail">
|
220
|
+
<a name="M000119"></a>
|
221
221
|
|
222
222
|
<div class="method-heading">
|
223
|
-
<a href="LongMath.src/
|
224
|
-
onclick="popupCode('LongMath.src/
|
223
|
+
<a href="LongMath.src/M000119.html" target="Code" class="method-signature"
|
224
|
+
onclick="popupCode('LongMath.src/M000119.html');return false;">
|
225
225
|
<span class="method-name">check_is_int</span><span class="method-args">(x, name="x")</span>
|
226
226
|
</a>
|
227
227
|
</div>
|
@@ -233,12 +233,12 @@ helper method for internal use: checks if parameter x is an Integer
|
|
233
233
|
</div>
|
234
234
|
</div>
|
235
235
|
|
236
|
-
<div id="method-
|
237
|
-
<a name="
|
236
|
+
<div id="method-M000120" class="method-detail">
|
237
|
+
<a name="M000120"></a>
|
238
238
|
|
239
239
|
<div class="method-heading">
|
240
|
-
<a href="LongMath.src/
|
241
|
-
onclick="popupCode('LongMath.src/
|
240
|
+
<a href="LongMath.src/M000120.html" target="Code" class="method-signature"
|
241
|
+
onclick="popupCode('LongMath.src/M000120.html');return false;">
|
242
242
|
<span class="method-name">check_is_ld</span><span class="method-args">(x, name="x")</span>
|
243
243
|
</a>
|
244
244
|
</div>
|
@@ -251,12 +251,12 @@ href="LongDecimal.html">LongDecimal</a>
|
|
251
251
|
</div>
|
252
252
|
</div>
|
253
253
|
|
254
|
-
<div id="method-
|
255
|
-
<a name="
|
254
|
+
<div id="method-M000122" class="method-detail">
|
255
|
+
<a name="M000122"></a>
|
256
256
|
|
257
257
|
<div class="method-heading">
|
258
|
-
<a href="LongMath.src/
|
259
|
-
onclick="popupCode('LongMath.src/
|
258
|
+
<a href="LongMath.src/M000122.html" target="Code" class="method-signature"
|
259
|
+
onclick="popupCode('LongMath.src/M000122.html');return false;">
|
260
260
|
<span class="method-name">check_is_mode</span><span class="method-args">(mode, name="mode")</span>
|
261
261
|
</a>
|
262
262
|
</div>
|
@@ -269,12 +269,12 @@ helper method for internal use: checks if parameter x is a rounding mode
|
|
269
269
|
</div>
|
270
270
|
</div>
|
271
271
|
|
272
|
-
<div id="method-
|
273
|
-
<a name="
|
272
|
+
<div id="method-M000121" class="method-detail">
|
273
|
+
<a name="M000121"></a>
|
274
274
|
|
275
275
|
<div class="method-heading">
|
276
|
-
<a href="LongMath.src/
|
277
|
-
onclick="popupCode('LongMath.src/
|
276
|
+
<a href="LongMath.src/M000121.html" target="Code" class="method-signature"
|
277
|
+
onclick="popupCode('LongMath.src/M000121.html');return false;">
|
278
278
|
<span class="method-name">check_is_prec</span><span class="method-args">(prec, name="prec")</span>
|
279
279
|
</a>
|
280
280
|
</div>
|
@@ -287,12 +287,12 @@ for the precision (scale) of a <a href="LongDecimal.html">LongDecimal</a>
|
|
287
287
|
</div>
|
288
288
|
</div>
|
289
289
|
|
290
|
-
<div id="method-
|
291
|
-
<a name="
|
290
|
+
<div id="method-M000118" class="method-detail">
|
291
|
+
<a name="M000118"></a>
|
292
292
|
|
293
293
|
<div class="method-heading">
|
294
|
-
<a href="LongMath.src/
|
295
|
-
onclick="popupCode('LongMath.src/
|
294
|
+
<a href="LongMath.src/M000118.html" target="Code" class="method-signature"
|
295
|
+
onclick="popupCode('LongMath.src/M000118.html');return false;">
|
296
296
|
<span class="method-name">check_word_len</span><span class="method-args">(word_len, name="word_len")</span>
|
297
297
|
</a>
|
298
298
|
</div>
|
@@ -305,12 +305,12 @@ splitting a number into parts
|
|
305
305
|
</div>
|
306
306
|
</div>
|
307
307
|
|
308
|
-
<div id="method-
|
309
|
-
<a name="
|
308
|
+
<div id="method-M000134" class="method-detail">
|
309
|
+
<a name="M000134"></a>
|
310
310
|
|
311
311
|
<div class="method-heading">
|
312
|
-
<a href="LongMath.src/
|
313
|
-
onclick="popupCode('LongMath.src/
|
312
|
+
<a href="LongMath.src/M000134.html" target="Code" class="method-signature"
|
313
|
+
onclick="popupCode('LongMath.src/M000134.html');return false;">
|
314
314
|
<span class="method-name">exp</span><span class="method-args">(x, prec, mode = LongDecimal::ROUND_HALF_DOWN)</span>
|
315
315
|
</a>
|
316
316
|
</div>
|
@@ -327,12 +327,12 @@ future versions.
|
|
327
327
|
</div>
|
328
328
|
</div>
|
329
329
|
|
330
|
-
<div id="method-
|
331
|
-
<a name="
|
330
|
+
<div id="method-M000136" class="method-detail">
|
331
|
+
<a name="M000136"></a>
|
332
332
|
|
333
333
|
<div class="method-heading">
|
334
|
-
<a href="LongMath.src/
|
335
|
-
onclick="popupCode('LongMath.src/
|
334
|
+
<a href="LongMath.src/M000136.html" target="Code" class="method-signature"
|
335
|
+
onclick="popupCode('LongMath.src/M000136.html');return false;">
|
336
336
|
<span class="method-name">exp10</span><span class="method-args">(x, prec, mode = LongDecimal::ROUND_HALF_DOWN)</span>
|
337
337
|
</a>
|
338
338
|
</div>
|
@@ -343,18 +343,17 @@ calc the base-10-exponential function of x to the given precision as <a
|
|
343
343
|
href="LongDecimal.html">LongDecimal</a>. Only supports values of x such
|
344
344
|
that the result still fits into a float (x <= 709). This limitation is
|
345
345
|
somewhat arbitrary, but it is enforced in order to avoid producing numbers
|
346
|
-
with the exponential function that exceed the memory.
|
347
|
-
future versions.
|
346
|
+
with the exponential function that exceed the memory.
|
348
347
|
</p>
|
349
348
|
</div>
|
350
349
|
</div>
|
351
350
|
|
352
|
-
<div id="method-
|
353
|
-
<a name="
|
351
|
+
<div id="method-M000135" class="method-detail">
|
352
|
+
<a name="M000135"></a>
|
354
353
|
|
355
354
|
<div class="method-heading">
|
356
|
-
<a href="LongMath.src/
|
357
|
-
onclick="popupCode('LongMath.src/
|
355
|
+
<a href="LongMath.src/M000135.html" target="Code" class="method-signature"
|
356
|
+
onclick="popupCode('LongMath.src/M000135.html');return false;">
|
358
357
|
<span class="method-name">exp2</span><span class="method-args">(x, prec, mode = LongDecimal::ROUND_HALF_DOWN)</span>
|
359
358
|
</a>
|
360
359
|
</div>
|
@@ -365,18 +364,17 @@ calc the base-2-exponential function of x to the given precision as <a
|
|
365
364
|
href="LongDecimal.html">LongDecimal</a>. Only supports values of x such
|
366
365
|
that the result still fits into a float (x <= 709). This limitation is
|
367
366
|
somewhat arbitrary, but it is enforced in order to avoid producing numbers
|
368
|
-
with the exponential function that exceed the memory.
|
369
|
-
future versions.
|
367
|
+
with the exponential function that exceed the memory.
|
370
368
|
</p>
|
371
369
|
</div>
|
372
370
|
</div>
|
373
371
|
|
374
|
-
<div id="method-
|
375
|
-
<a name="
|
372
|
+
<div id="method-M000137" class="method-detail">
|
373
|
+
<a name="M000137"></a>
|
376
374
|
|
377
375
|
<div class="method-heading">
|
378
|
-
<a href="LongMath.src/
|
379
|
-
onclick="popupCode('LongMath.src/
|
376
|
+
<a href="LongMath.src/M000137.html" target="Code" class="method-signature"
|
377
|
+
onclick="popupCode('LongMath.src/M000137.html');return false;">
|
380
378
|
<span class="method-name">exp_internal</span><span class="method-args">(x, prec = nil, final_mode = LongDecimal::ROUND_HALF_DOWN, j = nil, k = nil, iprec = nil, mode = LongDecimal::ROUND_HALF_DOWN, cache_result = true)</span>
|
381
379
|
</a>
|
382
380
|
</div>
|
@@ -391,12 +389,12 @@ if the default settings for the parameters do not work correctly
|
|
391
389
|
</div>
|
392
390
|
</div>
|
393
391
|
|
394
|
-
<div id="method-
|
395
|
-
<a name="
|
392
|
+
<div id="method-M000138" class="method-detail">
|
393
|
+
<a name="M000138"></a>
|
396
394
|
|
397
395
|
<div class="method-heading">
|
398
|
-
<a href="LongMath.src/
|
399
|
-
onclick="popupCode('LongMath.src/
|
396
|
+
<a href="LongMath.src/M000138.html" target="Code" class="method-signature"
|
397
|
+
onclick="popupCode('LongMath.src/M000138.html');return false;">
|
400
398
|
<span class="method-name">exp_raw</span><span class="method-args">(x, prec, j, k, iprec, mode)</span>
|
401
399
|
</a>
|
402
400
|
</div>
|
@@ -409,12 +407,12 @@ to be accurate to all digits that are provided.
|
|
409
407
|
</div>
|
410
408
|
</div>
|
411
409
|
|
412
|
-
<div id="method-
|
413
|
-
<a name="
|
410
|
+
<div id="method-M000129" class="method-detail">
|
411
|
+
<a name="M000129"></a>
|
414
412
|
|
415
413
|
<div class="method-heading">
|
416
|
-
<a href="LongMath.src/
|
417
|
-
onclick="popupCode('LongMath.src/
|
414
|
+
<a href="LongMath.src/M000129.html" target="Code" class="method-signature"
|
415
|
+
onclick="popupCode('LongMath.src/M000129.html');return false;">
|
418
416
|
<span class="method-name">gcd_with_high_power</span><span class="method-args">(x, b)</span>
|
419
417
|
</a>
|
420
418
|
</div>
|
@@ -427,12 +425,12 @@ exponent such that gcd(x, b**m) = gcd(x, b**n) for all m, n >= n0
|
|
427
425
|
</div>
|
428
426
|
</div>
|
429
427
|
|
430
|
-
<div id="method-
|
431
|
-
<a name="
|
428
|
+
<div id="method-M000132" class="method-detail">
|
429
|
+
<a name="M000132"></a>
|
432
430
|
|
433
431
|
<div class="method-heading">
|
434
|
-
<a href="LongMath.src/
|
435
|
-
onclick="popupCode('LongMath.src/
|
432
|
+
<a href="LongMath.src/M000132.html" target="Code" class="method-signature"
|
433
|
+
onclick="popupCode('LongMath.src/M000132.html');return false;">
|
436
434
|
<span class="method-name">int_digits10</span><span class="method-args">(n)</span>
|
437
435
|
</a>
|
438
436
|
</div>
|
@@ -444,12 +442,12 @@ find number of digits in base 10 needed to express the given number n
|
|
444
442
|
</div>
|
445
443
|
</div>
|
446
444
|
|
447
|
-
<div id="method-
|
448
|
-
<a name="
|
445
|
+
<div id="method-M000141" class="method-detail">
|
446
|
+
<a name="M000141"></a>
|
449
447
|
|
450
448
|
<div class="method-heading">
|
451
|
-
<a href="LongMath.src/
|
452
|
-
onclick="popupCode('LongMath.src/
|
449
|
+
<a href="LongMath.src/M000141.html" target="Code" class="method-signature"
|
450
|
+
onclick="popupCode('LongMath.src/M000141.html');return false;">
|
453
451
|
<span class="method-name">log</span><span class="method-args">(x, prec, mode = LongDecimal::ROUND_HALF_DOWN)</span>
|
454
452
|
</a>
|
455
453
|
</div>
|
@@ -462,12 +460,12 @@ href="LongDecimal.html">LongDecimal</a>.
|
|
462
460
|
</div>
|
463
461
|
</div>
|
464
462
|
|
465
|
-
<div id="method-
|
466
|
-
<a name="
|
463
|
+
<div id="method-M000142" class="method-detail">
|
464
|
+
<a name="M000142"></a>
|
467
465
|
|
468
466
|
<div class="method-heading">
|
469
|
-
<a href="LongMath.src/
|
470
|
-
onclick="popupCode('LongMath.src/
|
467
|
+
<a href="LongMath.src/M000142.html" target="Code" class="method-signature"
|
468
|
+
onclick="popupCode('LongMath.src/M000142.html');return false;">
|
471
469
|
<span class="method-name">log10</span><span class="method-args">(x, prec, mode = LongDecimal::ROUND_HALF_DOWN)</span>
|
472
470
|
</a>
|
473
471
|
</div>
|
@@ -480,12 +478,12 @@ href="LongDecimal.html">LongDecimal</a>.
|
|
480
478
|
</div>
|
481
479
|
</div>
|
482
480
|
|
483
|
-
<div id="method-
|
484
|
-
<a name="
|
481
|
+
<div id="method-M000143" class="method-detail">
|
482
|
+
<a name="M000143"></a>
|
485
483
|
|
486
484
|
<div class="method-heading">
|
487
|
-
<a href="LongMath.src/
|
488
|
-
onclick="popupCode('LongMath.src/
|
485
|
+
<a href="LongMath.src/M000143.html" target="Code" class="method-signature"
|
486
|
+
onclick="popupCode('LongMath.src/M000143.html');return false;">
|
489
487
|
<span class="method-name">log2</span><span class="method-args">(x, prec, mode = LongDecimal::ROUND_HALF_DOWN)</span>
|
490
488
|
</a>
|
491
489
|
</div>
|
@@ -498,12 +496,12 @@ href="LongDecimal.html">LongDecimal</a>.
|
|
498
496
|
</div>
|
499
497
|
</div>
|
500
498
|
|
501
|
-
<div id="method-
|
502
|
-
<a name="
|
499
|
+
<div id="method-M000144" class="method-detail">
|
500
|
+
<a name="M000144"></a>
|
503
501
|
|
504
502
|
<div class="method-heading">
|
505
|
-
<a href="LongMath.src/
|
506
|
-
onclick="popupCode('LongMath.src/
|
503
|
+
<a href="LongMath.src/M000144.html" target="Code" class="method-signature"
|
504
|
+
onclick="popupCode('LongMath.src/M000144.html');return false;">
|
507
505
|
<span class="method-name">log_internal</span><span class="method-args">(x, prec = nil, final_mode = LongDecimal::ROUND_HALF_DOWN, iprec = nil, mode = LongDecimal::ROUND_HALF_DOWN, cache_result = true)</span>
|
508
506
|
</a>
|
509
507
|
</div>
|
@@ -518,12 +516,12 @@ if the default settings for the parameters do not work correctly
|
|
518
516
|
</div>
|
519
517
|
</div>
|
520
518
|
|
521
|
-
<div id="method-
|
522
|
-
<a name="
|
519
|
+
<div id="method-M000145" class="method-detail">
|
520
|
+
<a name="M000145"></a>
|
523
521
|
|
524
522
|
<div class="method-heading">
|
525
|
-
<a href="LongMath.src/
|
526
|
-
onclick="popupCode('LongMath.src/
|
523
|
+
<a href="LongMath.src/M000145.html" target="Code" class="method-signature"
|
524
|
+
onclick="popupCode('LongMath.src/M000145.html');return false;">
|
527
525
|
<span class="method-name">log_raw</span><span class="method-args">(x, prec, iprec, mode)</span>
|
528
526
|
</a>
|
529
527
|
</div>
|
@@ -536,12 +534,12 @@ in order to ensure that all digits that are provided are correct.
|
|
536
534
|
</div>
|
537
535
|
</div>
|
538
536
|
|
539
|
-
<div id="method-
|
540
|
-
<a name="
|
537
|
+
<div id="method-M000124" class="method-detail">
|
538
|
+
<a name="M000124"></a>
|
541
539
|
|
542
540
|
<div class="method-heading">
|
543
|
-
<a href="LongMath.src/
|
544
|
-
onclick="popupCode('LongMath.src/
|
541
|
+
<a href="LongMath.src/M000124.html" target="Code" class="method-signature"
|
542
|
+
onclick="popupCode('LongMath.src/M000124.html');return false;">
|
545
543
|
<span class="method-name">merge_from_words</span><span class="method-args">(words, word_len = 32)</span>
|
546
544
|
</a>
|
547
545
|
</div>
|
@@ -549,17 +547,17 @@ in order to ensure that all digits that are provided are correct.
|
|
549
547
|
<div class="method-description">
|
550
548
|
<p>
|
551
549
|
concatenate numbers given in words as bit patterns (the opposite of <a
|
552
|
-
href="LongMath.html#
|
550
|
+
href="LongMath.html#M000123">split_to_words</a>)
|
553
551
|
</p>
|
554
552
|
</div>
|
555
553
|
</div>
|
556
554
|
|
557
|
-
<div id="method-
|
558
|
-
<a name="
|
555
|
+
<div id="method-M000131" class="method-detail">
|
556
|
+
<a name="M000131"></a>
|
559
557
|
|
560
558
|
<div class="method-heading">
|
561
|
-
<a href="LongMath.src/
|
562
|
-
onclick="popupCode('LongMath.src/
|
559
|
+
<a href="LongMath.src/M000131.html" target="Code" class="method-signature"
|
560
|
+
onclick="popupCode('LongMath.src/M000131.html');return false;">
|
563
561
|
<span class="method-name">multiplicity_of_10</span><span class="method-args">(n)</span>
|
564
562
|
</a>
|
565
563
|
</div>
|
@@ -571,12 +569,12 @@ how many times can n be divided by 10?
|
|
571
569
|
</div>
|
572
570
|
</div>
|
573
571
|
|
574
|
-
<div id="method-
|
575
|
-
<a name="
|
572
|
+
<div id="method-M000130" class="method-detail">
|
573
|
+
<a name="M000130"></a>
|
576
574
|
|
577
575
|
<div class="method-heading">
|
578
|
-
<a href="LongMath.src/
|
579
|
-
onclick="popupCode('LongMath.src/
|
576
|
+
<a href="LongMath.src/M000130.html" target="Code" class="method-signature"
|
577
|
+
onclick="popupCode('LongMath.src/M000130.html');return false;">
|
580
578
|
<span class="method-name">multiplicity_of_factor</span><span class="method-args">(x, prime_number)</span>
|
581
579
|
</a>
|
582
580
|
</div>
|
@@ -593,12 +591,12 @@ that exceed the range of Float
|
|
593
591
|
</div>
|
594
592
|
</div>
|
595
593
|
|
596
|
-
<div id="method-
|
597
|
-
<a name="
|
594
|
+
<div id="method-M000133" class="method-detail">
|
595
|
+
<a name="M000133"></a>
|
598
596
|
|
599
597
|
<div class="method-heading">
|
600
|
-
<a href="LongMath.src/
|
601
|
-
onclick="popupCode('LongMath.src/
|
598
|
+
<a href="LongMath.src/M000133.html" target="Code" class="method-signature"
|
599
|
+
onclick="popupCode('LongMath.src/M000133.html');return false;">
|
602
600
|
<span class="method-name">pi</span><span class="method-args">(prec, final_mode = LongDecimal::ROUND_HALF_DOWN, iprec = nil, mode = nil, cache_result = true)</span>
|
603
601
|
</a>
|
604
602
|
</div>
|
@@ -621,12 +619,12 @@ long result is really needed only once
|
|
621
619
|
</div>
|
622
620
|
</div>
|
623
621
|
|
624
|
-
<div id="method-
|
625
|
-
<a name="
|
622
|
+
<div id="method-M000147" class="method-detail">
|
623
|
+
<a name="M000147"></a>
|
626
624
|
|
627
625
|
<div class="method-heading">
|
628
|
-
<a href="LongMath.src/
|
629
|
-
onclick="popupCode('LongMath.src/
|
626
|
+
<a href="LongMath.src/M000147.html" target="Code" class="method-signature"
|
627
|
+
onclick="popupCode('LongMath.src/M000147.html');return false;">
|
630
628
|
<span class="method-name">power</span><span class="method-args">(x, y, prec, mode = LongDecimal::ROUND_HALF_DOWN)</span>
|
631
629
|
</a>
|
632
630
|
</div>
|
@@ -640,12 +638,12 @@ that exp(y) still fits into a float (y <= 709)
|
|
640
638
|
</div>
|
641
639
|
</div>
|
642
640
|
|
643
|
-
<div id="method-
|
644
|
-
<a name="
|
641
|
+
<div id="method-M000148" class="method-detail">
|
642
|
+
<a name="M000148"></a>
|
645
643
|
|
646
644
|
<div class="method-heading">
|
647
|
-
<a href="LongMath.src/
|
648
|
-
onclick="popupCode('LongMath.src/
|
645
|
+
<a href="LongMath.src/M000148.html" target="Code" class="method-signature"
|
646
|
+
onclick="popupCode('LongMath.src/M000148.html');return false;">
|
649
647
|
<span class="method-name">power_internal</span><span class="method-args">(x, y, prec = nil, final_mode = LongDecimal::ROUND_HALF_DOWN, iprec = nil, mode = LongDecimal::ROUND_HALF_DOWN)</span>
|
650
648
|
</a>
|
651
649
|
</div>
|
@@ -660,12 +658,12 @@ if the default settings for the parameters do not work correctly
|
|
660
658
|
</div>
|
661
659
|
</div>
|
662
660
|
|
663
|
-
<div id="method-
|
664
|
-
<a name="
|
661
|
+
<div id="method-M000123" class="method-detail">
|
662
|
+
<a name="M000123"></a>
|
665
663
|
|
666
664
|
<div class="method-heading">
|
667
|
-
<a href="LongMath.src/
|
668
|
-
onclick="popupCode('LongMath.src/
|
665
|
+
<a href="LongMath.src/M000123.html" target="Code" class="method-signature"
|
666
|
+
onclick="popupCode('LongMath.src/M000123.html');return false;">
|
669
667
|
<span class="method-name">split_to_words</span><span class="method-args">(x, word_len = 32)</span>
|
670
668
|
</a>
|
671
669
|
</div>
|
@@ -674,17 +672,17 @@ if the default settings for the parameters do not work correctly
|
|
674
672
|
<p>
|
675
673
|
split number (Integer) x into parts of word_len bits each such that the
|
676
674
|
concatenation of these parts as bit patterns is x (the opposite of <a
|
677
|
-
href="LongMath.html#
|
675
|
+
href="LongMath.html#M000124">merge_from_words</a>)
|
678
676
|
</p>
|
679
677
|
</div>
|
680
678
|
</div>
|
681
679
|
|
682
|
-
<div id="method-
|
683
|
-
<a name="
|
680
|
+
<div id="method-M000139" class="method-detail">
|
681
|
+
<a name="M000139"></a>
|
684
682
|
|
685
683
|
<div class="method-heading">
|
686
|
-
<a href="LongMath.src/
|
687
|
-
onclick="popupCode('LongMath.src/
|
684
|
+
<a href="LongMath.src/M000139.html" target="Code" class="method-signature"
|
685
|
+
onclick="popupCode('LongMath.src/M000139.html');return false;">
|
688
686
|
<span class="method-name">sqrt</span><span class="method-args">(x, prec, mode = LongDecimal::ROUND_HALF_DOWN)</span>
|
689
687
|
</a>
|
690
688
|
</div>
|
@@ -697,12 +695,12 @@ href="LongDecimal.html">LongDecimal</a>.
|
|
697
695
|
</div>
|
698
696
|
</div>
|
699
697
|
|
700
|
-
<div id="method-
|
701
|
-
<a name="
|
698
|
+
<div id="method-M000140" class="method-detail">
|
699
|
+
<a name="M000140"></a>
|
702
700
|
|
703
701
|
<div class="method-heading">
|
704
|
-
<a href="LongMath.src/
|
705
|
-
onclick="popupCode('LongMath.src/
|
702
|
+
<a href="LongMath.src/M000140.html" target="Code" class="method-signature"
|
703
|
+
onclick="popupCode('LongMath.src/M000140.html');return false;">
|
706
704
|
<span class="method-name">sqrt_with_remainder</span><span class="method-args">(x, prec)</span>
|
707
705
|
</a>
|
708
706
|
</div>
|
@@ -715,12 +713,12 @@ href="LongDecimal.html">LongDecimal</a> with remainder
|
|
715
713
|
</div>
|
716
714
|
</div>
|
717
715
|
|
718
|
-
<div id="method-
|
719
|
-
<a name="
|
716
|
+
<div id="method-M000125" class="method-detail">
|
717
|
+
<a name="M000125"></a>
|
720
718
|
|
721
719
|
<div class="method-heading">
|
722
|
-
<a href="LongMath.src/
|
723
|
-
onclick="popupCode('LongMath.src/
|
720
|
+
<a href="LongMath.src/M000125.html" target="Code" class="method-signature"
|
721
|
+
onclick="popupCode('LongMath.src/M000125.html');return false;">
|
724
722
|
<span class="method-name">sqrtb</span><span class="method-args">(x)</span>
|
725
723
|
</a>
|
726
724
|
</div>
|
@@ -733,12 +731,12 @@ result is rounded to an integer y such that y**2
|
|
733
731
|
</div>
|
734
732
|
</div>
|
735
733
|
|
736
|
-
<div id="method-
|
737
|
-
<a name="
|
734
|
+
<div id="method-M000126" class="method-detail">
|
735
|
+
<a name="M000126"></a>
|
738
736
|
|
739
737
|
<div class="method-heading">
|
740
|
-
<a href="LongMath.src/
|
741
|
-
onclick="popupCode('LongMath.src/
|
738
|
+
<a href="LongMath.src/M000126.html" target="Code" class="method-signature"
|
739
|
+
onclick="popupCode('LongMath.src/M000126.html');return false;">
|
742
740
|
<span class="method-name">sqrtb_with_remainder</span><span class="method-args">(x)</span>
|
743
741
|
</a>
|
744
742
|
</div>
|
@@ -755,12 +753,12 @@ result is rounded to an integer y such that y**2
|
|
755
753
|
</div>
|
756
754
|
</div>
|
757
755
|
|
758
|
-
<div id="method-
|
759
|
-
<a name="
|
756
|
+
<div id="method-M000127" class="method-detail">
|
757
|
+
<a name="M000127"></a>
|
760
758
|
|
761
759
|
<div class="method-heading">
|
762
|
-
<a href="LongMath.src/
|
763
|
-
onclick="popupCode('LongMath.src/
|
760
|
+
<a href="LongMath.src/M000127.html" target="Code" class="method-signature"
|
761
|
+
onclick="popupCode('LongMath.src/M000127.html');return false;">
|
764
762
|
<span class="method-name">sqrtw</span><span class="method-args">(x, n = 16)</span>
|
765
763
|
</a>
|
766
764
|
</div>
|
@@ -776,12 +774,12 @@ integer y such that y**2
|
|
776
774
|
</div>
|
777
775
|
</div>
|
778
776
|
|
779
|
-
<div id="method-
|
780
|
-
<a name="
|
777
|
+
<div id="method-M000128" class="method-detail">
|
778
|
+
<a name="M000128"></a>
|
781
779
|
|
782
780
|
<div class="method-heading">
|
783
|
-
<a href="LongMath.src/
|
784
|
-
onclick="popupCode('LongMath.src/
|
781
|
+
<a href="LongMath.src/M000128.html" target="Code" class="method-signature"
|
782
|
+
onclick="popupCode('LongMath.src/M000128.html');return false;">
|
785
783
|
<span class="method-name">sqrtw_with_remainder</span><span class="method-args">(x, n = 16)</span>
|
786
784
|
</a>
|
787
785
|
</div>
|