long-decimal 0.00.16 → 0.00.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +16 -15
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/doc/classes/LongDecimal.html +15 -8
- data/doc/classes/LongDecimal.src/M000041.html +3 -2
- data/doc/classes/LongDecimal.src/M000042.html +1 -1
- data/doc/classes/LongDecimal.src/M000043.html +1 -1
- data/doc/classes/LongDecimal.src/M000044.html +1 -3
- data/doc/classes/LongDecimal.src/M000045.html +1 -1
- data/doc/classes/LongDecimal.src/M000046.html +1 -1
- data/doc/classes/LongDecimal.src/M000047.html +1 -1
- data/doc/classes/LongDecimal.src/M000048.html +1 -1
- data/doc/classes/LongDecimal.src/M000049.html +7 -3
- data/doc/classes/LongDecimal.src/M000050.html +1 -1
- data/doc/classes/LongDecimal.src/M000051.html +1 -1
- data/doc/classes/LongDecimal.src/M000052.html +1 -1
- data/doc/classes/LongDecimal.src/M000053.html +1 -1
- data/doc/classes/LongDecimal.src/M000054.html +1 -1
- data/doc/classes/LongDecimal.src/M000055.html +1 -1
- data/doc/classes/LongDecimal.src/M000056.html +1 -1
- data/doc/classes/LongDecimal.src/M000058.html +1 -1
- data/doc/classes/LongDecimal.src/M000059.html +1 -1
- data/doc/classes/LongDecimal.src/M000060.html +1 -1
- data/doc/classes/LongDecimal.src/M000061.html +1 -1
- data/doc/classes/LongDecimal.src/M000062.html +1 -1
- data/doc/classes/LongDecimal.src/M000063.html +1 -1
- data/doc/classes/LongDecimal.src/M000064.html +1 -1
- data/doc/classes/LongDecimal.src/M000065.html +1 -1
- data/doc/classes/LongDecimal.src/M000066.html +1 -1
- data/doc/classes/LongDecimal.src/M000067.html +1 -1
- data/doc/classes/LongDecimal.src/M000068.html +1 -1
- data/doc/classes/LongDecimal.src/M000069.html +1 -1
- data/doc/classes/LongDecimal.src/M000070.html +1 -1
- data/doc/classes/LongDecimal.src/M000071.html +1 -1
- data/doc/classes/LongDecimal.src/M000072.html +1 -1
- data/doc/classes/LongDecimal.src/M000073.html +1 -1
- data/doc/classes/LongDecimal.src/M000074.html +1 -1
- data/doc/classes/LongDecimal.src/M000075.html +1 -1
- data/doc/classes/LongDecimal.src/M000076.html +1 -1
- data/doc/classes/LongDecimal.src/M000077.html +1 -1
- data/doc/classes/LongDecimal.src/M000078.html +1 -1
- data/doc/classes/LongDecimal.src/M000079.html +1 -1
- data/doc/classes/LongDecimal.src/M000080.html +1 -1
- data/doc/classes/LongDecimal.src/M000081.html +1 -1
- data/doc/classes/LongDecimal.src/M000082.html +1 -1
- data/doc/classes/LongDecimal.src/M000083.html +1 -1
- data/doc/classes/LongDecimal.src/M000084.html +1 -1
- data/doc/classes/LongDecimal.src/M000085.html +1 -1
- data/doc/classes/LongDecimal.src/M000086.html +1 -1
- data/doc/classes/LongDecimal.src/M000087.html +1 -1
- data/doc/classes/LongDecimal.src/M000088.html +1 -1
- data/doc/classes/LongDecimal.src/M000089.html +30 -4
- data/doc/classes/LongDecimal.src/M000090.html +1 -1
- data/doc/classes/LongDecimal.src/M000091.html +1 -1
- data/doc/classes/LongDecimal.src/M000094.html +1 -1
- data/doc/classes/LongDecimal.src/M000095.html +1 -1
- data/doc/classes/LongDecimal.src/M000096.html +1 -1
- data/doc/classes/LongDecimal.src/M000097.html +1 -1
- data/doc/classes/LongDecimal.src/M000098.html +1 -1
- data/doc/classes/LongDecimal.src/M000099.html +1 -1
- data/doc/classes/LongDecimalBase.html +58 -57
- data/doc/classes/LongDecimalBase.src/M000102.html +4 -4
- data/doc/classes/LongDecimalBase.src/M000103.html +4 -4
- data/doc/classes/LongDecimalBase.src/M000104.html +4 -4
- data/doc/classes/LongDecimalBase.src/M000105.html +4 -4
- data/doc/classes/LongDecimalBase.src/M000106.html +4 -4
- data/doc/classes/LongDecimalBase.src/M000107.html +18 -0
- data/doc/classes/LongDecimalBase.src/M000110.html +9 -5
- data/doc/classes/LongDecimalBase.src/M000111.html +5 -4
- data/doc/classes/LongDecimalBase.src/M000112.html +18 -0
- data/doc/classes/LongDecimalQuot.html +18 -13
- data/doc/classes/LongDecimalQuot.src/M000003.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000004.html +1 -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 +1 -1
- data/doc/classes/LongDecimalQuot.src/M000008.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000009.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000010.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000011.html +3 -3
- data/doc/classes/LongDecimalQuot.src/M000012.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000013.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000014.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000015.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000016.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000017.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000018.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000019.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000020.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000021.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000022.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000023.html +35 -2
- data/doc/classes/LongDecimalQuot.src/M000024.html +20 -4
- data/doc/classes/LongDecimalQuot.src/M000025.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000026.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000027.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000028.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000029.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000032.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000033.html +1 -1
- data/doc/classes/LongDecimalRoundingMode/RoundingModeClass.html +5 -5
- data/doc/classes/LongDecimalRoundingMode/RoundingModeClass.src/M000137.html +22 -0
- data/doc/classes/LongMath.html +135 -116
- data/doc/classes/LongMath.src/M000113.html +5 -4
- data/doc/classes/LongMath.src/M000114.html +4 -4
- data/doc/classes/LongMath.src/M000115.html +4 -5
- data/doc/classes/LongMath.src/M000116.html +5 -4
- data/doc/classes/LongMath.src/M000117.html +4 -18
- data/doc/classes/LongMath.src/M000118.html +14 -14
- data/doc/classes/LongMath.src/M000119.html +18 -5
- data/doc/classes/LongMath.src/M000120.html +5 -29
- data/doc/classes/LongMath.src/M000121.html +29 -5
- data/doc/classes/LongMath.src/M000122.html +5 -56
- data/doc/classes/LongMath.src/M000123.html +54 -19
- data/doc/classes/LongMath.src/M000124.html +20 -35
- data/doc/classes/LongMath.src/M000125.html +31 -27
- data/doc/classes/LongMath.src/M000126.html +32 -8
- data/doc/classes/LongMath.src/M000127.html +8 -13
- data/doc/classes/LongMath.src/M000128.html +13 -82
- data/doc/classes/LongMath.src/M000129.html +79 -4
- data/doc/classes/LongMath.src/M000130.html +4 -14
- data/doc/classes/LongMath.src/M000131.html +4 -14
- data/doc/classes/LongMath.src/M000132.html +13 -148
- data/doc/classes/LongMath.src/M000133.html +14 -8
- data/doc/classes/LongMath.src/M000134.html +127 -3
- data/doc/classes/LongMath.src/M000135.html +25 -0
- data/doc/classes/LongMath.src/M000136.html +42 -0
- data/doc/classes/Numeric.html +5 -2
- data/doc/classes/Numeric.src/M000100.html +8 -3
- data/doc/classes/Rational.html +158 -0
- data/doc/classes/Rational.src/M000101.html +23 -0
- data/doc/created.rid +1 -1
- data/doc/dot/f_0.dot +9 -0
- data/doc/dot/f_0.png +0 -0
- 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_class_index.html +1 -0
- data/doc/fr_method_index.html +56 -54
- data/lib/long-decimal.rb +147 -29
- data/test/testlongdecimal.rb +58 -5
- data/version.rb +1 -1
- metadata +10 -3
- data/doc/files/lib/long-decimal_rb.html +0 -187
@@ -10,7 +10,7 @@
|
|
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
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line 1429</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-operator">%</span>(<span class="ruby-identifier">other</span>)
|
15
15
|
<span class="ruby-identifier">q</span>, <span class="ruby-identifier">r</span> = <span class="ruby-identifier">divmod</span> <span class="ruby-identifier">other</span>
|
16
16
|
<span class="ruby-identifier">r</span>
|
@@ -10,7 +10,7 @@
|
|
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
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line 1437</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">abs</span>
|
15
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>)
|
16
16
|
<span class="ruby-keyword kw">end</span></pre>
|
@@ -10,27 +10,38 @@
|
|
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
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line 1451</span>
|
14
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
15
|
|
16
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
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
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
19
|
|
20
|
-
<span class="ruby-identifier">factor</span> = <span class="ruby-value">10</span><span class="ruby-operator">**</span><span class="ruby-identifier">new_scale</span>
|
21
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>
|
22
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
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
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>
|
25
27
|
<span class="ruby-identifier">prod</span> = <span class="ruby-identifier">numerator</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">factor</span>
|
26
28
|
<span class="ruby-identifier">divisor</span> = <span class="ruby-identifier">denominator</span>
|
27
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>)
|
28
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>
|
29
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>
|
30
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>)
|
31
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>
|
32
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
|
+
|
33
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>
|
34
45
|
<span class="ruby-identifier">rem</span> <span class="ruby-operator">-=</span> <span class="ruby-identifier">divisor</span>
|
35
46
|
<span class="ruby-identifier">quot</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
|
36
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>
|
@@ -38,14 +49,30 @@
|
|
38
49
|
<span class="ruby-keyword kw">end</span>
|
39
50
|
|
40
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>
|
41
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>
|
42
57
|
<span class="ruby-keyword kw">end</span>
|
43
58
|
|
44
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>
|
45
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
|
+
|
46
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>
|
47
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
|
+
|
48
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>
|
49
76
|
<span class="ruby-identifier">abs_rem</span> = <span class="ruby-identifier">rem</span>.<span class="ruby-identifier">abs</span>
|
50
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>
|
51
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>
|
@@ -68,10 +95,16 @@
|
|
68
95
|
<span class="ruby-keyword kw">end</span>
|
69
96
|
|
70
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>
|
71
101
|
<span class="ruby-identifier">quot</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">sign_quot</span>
|
72
102
|
<span class="ruby-keyword kw">end</span>
|
103
|
+
|
104
|
+
<span class="ruby-comment cmt"># put together result</span>
|
73
105
|
<span class="ruby-identifier">new_int_val</span> = <span class="ruby-identifier">quot</span>
|
74
106
|
<span class="ruby-constant">LongDecimal</span>(<span class="ruby-identifier">new_int_val</span>, <span class="ruby-identifier">new_scale</span>)
|
107
|
+
|
75
108
|
<span class="ruby-keyword kw">end</span></pre>
|
76
109
|
</body>
|
77
110
|
</html>
|
@@ -10,27 +10,43 @@
|
|
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
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line 1556</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">coerce</span>(<span class="ruby-identifier">other</span>)
|
15
|
+
|
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>
|
16
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
|
+
|
17
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>
|
18
22
|
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">other</span>, <span class="ruby-keyword kw">self</span>
|
19
|
-
|
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>
|
20
27
|
<span class="ruby-identifier">s</span> = <span class="ruby-identifier">scale</span>
|
21
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>
|
22
|
-
|
23
|
-
<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">scale</span>), <span class="ruby-keyword kw">self</span>
|
29
|
+
|
24
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>
|
25
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
|
+
|
26
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>
|
27
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
|
+
|
28
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>
|
29
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>)
|
30
43
|
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">o</span>, <span class="ruby-identifier">s</span>
|
44
|
+
|
31
45
|
<span class="ruby-keyword kw">else</span>
|
46
|
+
<span class="ruby-comment cmt"># non-numeric types do not work at all</span>
|
32
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>
|
33
48
|
<span class="ruby-keyword kw">end</span>
|
49
|
+
|
34
50
|
<span class="ruby-keyword kw">end</span></pre>
|
35
51
|
</body>
|
36
52
|
</html>
|
@@ -10,7 +10,7 @@
|
|
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
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line 1604</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-operator">==</span>(<span class="ruby-identifier">other</span>)
|
15
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>
|
@@ -10,7 +10,7 @@
|
|
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
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line 1612</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">zero?</span>
|
15
15
|
<span class="ruby-ivar">@rat</span>.<span class="ruby-identifier">zero?</span>
|
16
16
|
<span class="ruby-keyword kw">end</span></pre>
|
@@ -10,7 +10,7 @@
|
|
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
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line 1620</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">one?</span>
|
15
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>
|
@@ -10,7 +10,7 @@
|
|
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
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line 1627</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">is_int?</span>
|
15
15
|
<span class="ruby-identifier">denominator</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>
|
16
16
|
<span class="ruby-keyword kw">end</span></pre>
|
@@ -10,7 +10,7 @@
|
|
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
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line 1634</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">sgn</span>
|
15
15
|
<span class="ruby-identifier">numerator</span> <span class="ruby-operator"><=></span> <span class="ruby-value">0</span>
|
16
16
|
<span class="ruby-keyword kw">end</span></pre>
|
@@ -10,7 +10,7 @@
|
|
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
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line 1643</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">hash</span>
|
15
15
|
<span class="ruby-identifier">rat</span>.<span class="ruby-identifier">hash</span> <span class="ruby-operator">^</span> <span class="ruby-identifier">scale</span>.<span class="ruby-identifier">hash</span>
|
16
16
|
<span class="ruby-keyword kw">end</span></pre>
|
@@ -10,7 +10,7 @@
|
|
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
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line 1651</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">inspect</span>
|
15
15
|
<span class="ruby-identifier">sprintf</span>(<span class="ruby-value str">"LongDecimalQuot(Rational(%s, %s), %s)"</span>, <span class="ruby-identifier">numerator</span>.<span class="ruby-identifier">inspect</span>, <span class="ruby-identifier">denominator</span>.<span class="ruby-identifier">inspect</span>, <span class="ruby-identifier">scale</span>.<span class="ruby-identifier">inspect</span>)
|
16
16
|
<span class="ruby-keyword kw">end</span></pre>
|
@@ -101,7 +101,7 @@ 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="#
|
104
|
+
<a href="#M000137"><=></a>
|
105
105
|
</div>
|
106
106
|
</div>
|
107
107
|
|
@@ -130,12 +130,12 @@ by <a href="../LongDecimal.html">LongDecimal</a>
|
|
130
130
|
<div id="methods">
|
131
131
|
<h3 class="section-bar">Public Instance methods</h3>
|
132
132
|
|
133
|
-
<div id="method-
|
134
|
-
<a name="
|
133
|
+
<div id="method-M000137" class="method-detail">
|
134
|
+
<a name="M000137"></a>
|
135
135
|
|
136
136
|
<div class="method-heading">
|
137
|
-
<a href="RoundingModeClass.src/
|
138
|
-
onclick="popupCode('RoundingModeClass.src/
|
137
|
+
<a href="RoundingModeClass.src/M000137.html" target="Code" class="method-signature"
|
138
|
+
onclick="popupCode('RoundingModeClass.src/M000137.html');return false;">
|
139
139
|
<span class="method-name"><=></span><span class="method-args">(o)</span>
|
140
140
|
</a>
|
141
141
|
</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>
|
data/doc/classes/LongMath.html
CHANGED
@@ -99,29 +99,30 @@ href="LongDecimal.html">LongDecimal</a> instead of Float.
|
|
99
99
|
<h3 class="section-bar">Methods</h3>
|
100
100
|
|
101
101
|
<div class="name-list">
|
102
|
-
<a href="#
|
103
|
-
<a href="#
|
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="#M000120">
|
123
|
-
<a href="#M000121">
|
124
|
-
<a href="#M000122">
|
102
|
+
<a href="#M000128">calc_iprec_for_exp</a>
|
103
|
+
<a href="#M000126">calc_pi</a>
|
104
|
+
<a href="#M000114">check_is_int</a>
|
105
|
+
<a href="#M000115">check_is_ld</a>
|
106
|
+
<a href="#M000117">check_is_mode</a>
|
107
|
+
<a href="#M000116">check_is_prec</a>
|
108
|
+
<a href="#M000113">check_word_len</a>
|
109
|
+
<a href="#M000127">exp</a>
|
110
|
+
<a href="#M000129">exp_internal</a>
|
111
|
+
<a href="#M000124">gcd_with_high_power</a>
|
112
|
+
<a href="#M000131">log</a>
|
113
|
+
<a href="#M000132">log10</a>
|
114
|
+
<a href="#M000133">log2</a>
|
115
|
+
<a href="#M000134">log_internal</a>
|
116
|
+
<a href="#M000119">merge_from_words</a>
|
117
|
+
<a href="#M000125">multiplicity_of_factor</a>
|
118
|
+
<a href="#M000135">power</a>
|
119
|
+
<a href="#M000136">power_internal</a>
|
120
|
+
<a href="#M000118">split_to_words</a>
|
121
|
+
<a href="#M000130">sqrt</a>
|
122
|
+
<a href="#M000120">sqrtb</a>
|
123
|
+
<a href="#M000121">sqrtb_with_remainder</a>
|
124
|
+
<a href="#M000122">sqrtw</a>
|
125
|
+
<a href="#M000123">sqrtw_with_remainder</a>
|
125
126
|
</div>
|
126
127
|
</div>
|
127
128
|
|
@@ -178,12 +179,12 @@ href="LongDecimal.html">LongDecimal</a> instead of Float.
|
|
178
179
|
<div id="methods">
|
179
180
|
<h3 class="section-bar">Public Class methods</h3>
|
180
181
|
|
181
|
-
<div id="method-
|
182
|
-
<a name="
|
182
|
+
<div id="method-M000128" class="method-detail">
|
183
|
+
<a name="M000128"></a>
|
183
184
|
|
184
185
|
<div class="method-heading">
|
185
|
-
<a href="LongMath.src/
|
186
|
-
onclick="popupCode('LongMath.src/
|
186
|
+
<a href="LongMath.src/M000128.html" target="Code" class="method-signature"
|
187
|
+
onclick="popupCode('LongMath.src/M000128.html');return false;">
|
187
188
|
<span class="method-name">calc_iprec_for_exp</span><span class="method-args">(x, prec)</span>
|
188
189
|
</a>
|
189
190
|
</div>
|
@@ -195,12 +196,12 @@ private helper method for exponentiation calculate internal precision
|
|
195
196
|
</div>
|
196
197
|
</div>
|
197
198
|
|
198
|
-
<div id="method-
|
199
|
-
<a name="
|
199
|
+
<div id="method-M000126" class="method-detail">
|
200
|
+
<a name="M000126"></a>
|
200
201
|
|
201
202
|
<div class="method-heading">
|
202
|
-
<a href="LongMath.src/
|
203
|
-
onclick="popupCode('LongMath.src/
|
203
|
+
<a href="LongMath.src/M000126.html" target="Code" class="method-signature"
|
204
|
+
onclick="popupCode('LongMath.src/M000126.html');return false;">
|
204
205
|
<span class="method-name">calc_pi</span><span class="method-args">(prec, final_mode = LongDecimal::ROUND_HALF_DOWN)</span>
|
205
206
|
</a>
|
206
207
|
</div>
|
@@ -219,12 +220,12 @@ href="LongDecimal.html">LongDecimal</a>. ;-)
|
|
219
220
|
</div>
|
220
221
|
</div>
|
221
222
|
|
222
|
-
<div id="method-
|
223
|
-
<a name="
|
223
|
+
<div id="method-M000114" class="method-detail">
|
224
|
+
<a name="M000114"></a>
|
224
225
|
|
225
226
|
<div class="method-heading">
|
226
|
-
<a href="LongMath.src/
|
227
|
-
onclick="popupCode('LongMath.src/
|
227
|
+
<a href="LongMath.src/M000114.html" target="Code" class="method-signature"
|
228
|
+
onclick="popupCode('LongMath.src/M000114.html');return false;">
|
228
229
|
<span class="method-name">check_is_int</span><span class="method-args">(x, name="x")</span>
|
229
230
|
</a>
|
230
231
|
</div>
|
@@ -236,12 +237,12 @@ helper method for internal use: checks if parameter x is an Integer
|
|
236
237
|
</div>
|
237
238
|
</div>
|
238
239
|
|
239
|
-
<div id="method-
|
240
|
-
<a name="
|
240
|
+
<div id="method-M000115" class="method-detail">
|
241
|
+
<a name="M000115"></a>
|
241
242
|
|
242
243
|
<div class="method-heading">
|
243
|
-
<a href="LongMath.src/
|
244
|
-
onclick="popupCode('LongMath.src/
|
244
|
+
<a href="LongMath.src/M000115.html" target="Code" class="method-signature"
|
245
|
+
onclick="popupCode('LongMath.src/M000115.html');return false;">
|
245
246
|
<span class="method-name">check_is_ld</span><span class="method-args">(x, name="x")</span>
|
246
247
|
</a>
|
247
248
|
</div>
|
@@ -254,12 +255,12 @@ href="LongDecimal.html">LongDecimal</a>
|
|
254
255
|
</div>
|
255
256
|
</div>
|
256
257
|
|
257
|
-
<div id="method-
|
258
|
-
<a name="
|
258
|
+
<div id="method-M000117" class="method-detail">
|
259
|
+
<a name="M000117"></a>
|
259
260
|
|
260
261
|
<div class="method-heading">
|
261
|
-
<a href="LongMath.src/
|
262
|
-
onclick="popupCode('LongMath.src/
|
262
|
+
<a href="LongMath.src/M000117.html" target="Code" class="method-signature"
|
263
|
+
onclick="popupCode('LongMath.src/M000117.html');return false;">
|
263
264
|
<span class="method-name">check_is_mode</span><span class="method-args">(mode, name="mode")</span>
|
264
265
|
</a>
|
265
266
|
</div>
|
@@ -272,12 +273,12 @@ helper method for internal use: checks if parameter x is a rounding mode
|
|
272
273
|
</div>
|
273
274
|
</div>
|
274
275
|
|
275
|
-
<div id="method-
|
276
|
-
<a name="
|
276
|
+
<div id="method-M000116" class="method-detail">
|
277
|
+
<a name="M000116"></a>
|
277
278
|
|
278
279
|
<div class="method-heading">
|
279
|
-
<a href="LongMath.src/
|
280
|
-
onclick="popupCode('LongMath.src/
|
280
|
+
<a href="LongMath.src/M000116.html" target="Code" class="method-signature"
|
281
|
+
onclick="popupCode('LongMath.src/M000116.html');return false;">
|
281
282
|
<span class="method-name">check_is_prec</span><span class="method-args">(prec, name="prec")</span>
|
282
283
|
</a>
|
283
284
|
</div>
|
@@ -290,12 +291,12 @@ for the precision (scale) of a <a href="LongDecimal.html">LongDecimal</a>
|
|
290
291
|
</div>
|
291
292
|
</div>
|
292
293
|
|
293
|
-
<div id="method-
|
294
|
-
<a name="
|
294
|
+
<div id="method-M000113" class="method-detail">
|
295
|
+
<a name="M000113"></a>
|
295
296
|
|
296
297
|
<div class="method-heading">
|
297
|
-
<a href="LongMath.src/
|
298
|
-
onclick="popupCode('LongMath.src/
|
298
|
+
<a href="LongMath.src/M000113.html" target="Code" class="method-signature"
|
299
|
+
onclick="popupCode('LongMath.src/M000113.html');return false;">
|
299
300
|
<span class="method-name">check_word_len</span><span class="method-args">(word_len, name="word_len")</span>
|
300
301
|
</a>
|
301
302
|
</div>
|
@@ -308,12 +309,12 @@ splitting a number into parts
|
|
308
309
|
</div>
|
309
310
|
</div>
|
310
311
|
|
311
|
-
<div id="method-
|
312
|
-
<a name="
|
312
|
+
<div id="method-M000127" class="method-detail">
|
313
|
+
<a name="M000127"></a>
|
313
314
|
|
314
315
|
<div class="method-heading">
|
315
|
-
<a href="LongMath.src/
|
316
|
-
onclick="popupCode('LongMath.src/
|
316
|
+
<a href="LongMath.src/M000127.html" target="Code" class="method-signature"
|
317
|
+
onclick="popupCode('LongMath.src/M000127.html');return false;">
|
317
318
|
<span class="method-name">exp</span><span class="method-args">(x, prec, mode = LongDecimal::ROUND_HALF_DOWN)</span>
|
318
319
|
</a>
|
319
320
|
</div>
|
@@ -330,12 +331,12 @@ future versions.
|
|
330
331
|
</div>
|
331
332
|
</div>
|
332
333
|
|
333
|
-
<div id="method-
|
334
|
-
<a name="
|
334
|
+
<div id="method-M000129" class="method-detail">
|
335
|
+
<a name="M000129"></a>
|
335
336
|
|
336
337
|
<div class="method-heading">
|
337
|
-
<a href="LongMath.src/
|
338
|
-
onclick="popupCode('LongMath.src/
|
338
|
+
<a href="LongMath.src/M000129.html" target="Code" class="method-signature"
|
339
|
+
onclick="popupCode('LongMath.src/M000129.html');return false;">
|
339
340
|
<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)</span>
|
340
341
|
</a>
|
341
342
|
</div>
|
@@ -350,12 +351,12 @@ if the default settings for the parameters do not work correctly
|
|
350
351
|
</div>
|
351
352
|
</div>
|
352
353
|
|
353
|
-
<div id="method-
|
354
|
-
<a name="
|
354
|
+
<div id="method-M000124" class="method-detail">
|
355
|
+
<a name="M000124"></a>
|
355
356
|
|
356
357
|
<div class="method-heading">
|
357
|
-
<a href="LongMath.src/
|
358
|
-
onclick="popupCode('LongMath.src/
|
358
|
+
<a href="LongMath.src/M000124.html" target="Code" class="method-signature"
|
359
|
+
onclick="popupCode('LongMath.src/M000124.html');return false;">
|
359
360
|
<span class="method-name">gcd_with_high_power</span><span class="method-args">(x, b)</span>
|
360
361
|
</a>
|
361
362
|
</div>
|
@@ -368,12 +369,12 @@ exponent such that gcd(x, b**m) = gcd(x, b**n) for all m, n >= n0
|
|
368
369
|
</div>
|
369
370
|
</div>
|
370
371
|
|
371
|
-
<div id="method-
|
372
|
-
<a name="
|
372
|
+
<div id="method-M000131" class="method-detail">
|
373
|
+
<a name="M000131"></a>
|
373
374
|
|
374
375
|
<div class="method-heading">
|
375
|
-
<a href="LongMath.src/
|
376
|
-
onclick="popupCode('LongMath.src/
|
376
|
+
<a href="LongMath.src/M000131.html" target="Code" class="method-signature"
|
377
|
+
onclick="popupCode('LongMath.src/M000131.html');return false;">
|
377
378
|
<span class="method-name">log</span><span class="method-args">(x, prec, mode = LongDecimal::ROUND_HALF_DOWN)</span>
|
378
379
|
</a>
|
379
380
|
</div>
|
@@ -386,12 +387,12 @@ href="LongDecimal.html">LongDecimal</a>.
|
|
386
387
|
</div>
|
387
388
|
</div>
|
388
389
|
|
389
|
-
<div id="method-
|
390
|
-
<a name="
|
390
|
+
<div id="method-M000132" class="method-detail">
|
391
|
+
<a name="M000132"></a>
|
391
392
|
|
392
393
|
<div class="method-heading">
|
393
|
-
<a href="LongMath.src/
|
394
|
-
onclick="popupCode('LongMath.src/
|
394
|
+
<a href="LongMath.src/M000132.html" target="Code" class="method-signature"
|
395
|
+
onclick="popupCode('LongMath.src/M000132.html');return false;">
|
395
396
|
<span class="method-name">log10</span><span class="method-args">(x, prec, mode = LongDecimal::ROUND_HALF_DOWN)</span>
|
396
397
|
</a>
|
397
398
|
</div>
|
@@ -404,12 +405,12 @@ href="LongDecimal.html">LongDecimal</a>.
|
|
404
405
|
</div>
|
405
406
|
</div>
|
406
407
|
|
407
|
-
<div id="method-
|
408
|
-
<a name="
|
408
|
+
<div id="method-M000133" class="method-detail">
|
409
|
+
<a name="M000133"></a>
|
409
410
|
|
410
411
|
<div class="method-heading">
|
411
|
-
<a href="LongMath.src/
|
412
|
-
onclick="popupCode('LongMath.src/
|
412
|
+
<a href="LongMath.src/M000133.html" target="Code" class="method-signature"
|
413
|
+
onclick="popupCode('LongMath.src/M000133.html');return false;">
|
413
414
|
<span class="method-name">log2</span><span class="method-args">(x, prec, mode = LongDecimal::ROUND_HALF_DOWN)</span>
|
414
415
|
</a>
|
415
416
|
</div>
|
@@ -422,12 +423,12 @@ href="LongDecimal.html">LongDecimal</a>.
|
|
422
423
|
</div>
|
423
424
|
</div>
|
424
425
|
|
425
|
-
<div id="method-
|
426
|
-
<a name="
|
426
|
+
<div id="method-M000134" class="method-detail">
|
427
|
+
<a name="M000134"></a>
|
427
428
|
|
428
429
|
<div class="method-heading">
|
429
|
-
<a href="LongMath.src/
|
430
|
-
onclick="popupCode('LongMath.src/
|
430
|
+
<a href="LongMath.src/M000134.html" target="Code" class="method-signature"
|
431
|
+
onclick="popupCode('LongMath.src/M000134.html');return false;">
|
431
432
|
<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)</span>
|
432
433
|
</a>
|
433
434
|
</div>
|
@@ -442,12 +443,12 @@ if the default settings for the parameters do not work correctly
|
|
442
443
|
</div>
|
443
444
|
</div>
|
444
445
|
|
445
|
-
<div id="method-
|
446
|
-
<a name="
|
446
|
+
<div id="method-M000119" class="method-detail">
|
447
|
+
<a name="M000119"></a>
|
447
448
|
|
448
449
|
<div class="method-heading">
|
449
|
-
<a href="LongMath.src/
|
450
|
-
onclick="popupCode('LongMath.src/
|
450
|
+
<a href="LongMath.src/M000119.html" target="Code" class="method-signature"
|
451
|
+
onclick="popupCode('LongMath.src/M000119.html');return false;">
|
451
452
|
<span class="method-name">merge_from_words</span><span class="method-args">(words, word_len = 32)</span>
|
452
453
|
</a>
|
453
454
|
</div>
|
@@ -455,17 +456,17 @@ if the default settings for the parameters do not work correctly
|
|
455
456
|
<div class="method-description">
|
456
457
|
<p>
|
457
458
|
concatenate numbers given in words as bit patterns (the opposite of <a
|
458
|
-
href="LongMath.html#
|
459
|
+
href="LongMath.html#M000118">split_to_words</a>)
|
459
460
|
</p>
|
460
461
|
</div>
|
461
462
|
</div>
|
462
463
|
|
463
|
-
<div id="method-
|
464
|
-
<a name="
|
464
|
+
<div id="method-M000125" class="method-detail">
|
465
|
+
<a name="M000125"></a>
|
465
466
|
|
466
467
|
<div class="method-heading">
|
467
|
-
<a href="LongMath.src/
|
468
|
-
onclick="popupCode('LongMath.src/
|
468
|
+
<a href="LongMath.src/M000125.html" target="Code" class="method-signature"
|
469
|
+
onclick="popupCode('LongMath.src/M000125.html');return false;">
|
469
470
|
<span class="method-name">multiplicity_of_factor</span><span class="method-args">(x, prime_number)</span>
|
470
471
|
</a>
|
471
472
|
</div>
|
@@ -482,12 +483,12 @@ that exceed the range of Float
|
|
482
483
|
</div>
|
483
484
|
</div>
|
484
485
|
|
485
|
-
<div id="method-
|
486
|
-
<a name="
|
486
|
+
<div id="method-M000135" class="method-detail">
|
487
|
+
<a name="M000135"></a>
|
487
488
|
|
488
489
|
<div class="method-heading">
|
489
|
-
<a href="LongMath.src/
|
490
|
-
onclick="popupCode('LongMath.src/
|
490
|
+
<a href="LongMath.src/M000135.html" target="Code" class="method-signature"
|
491
|
+
onclick="popupCode('LongMath.src/M000135.html');return false;">
|
491
492
|
<span class="method-name">power</span><span class="method-args">(x, y, prec, mode = LongDecimal::ROUND_HALF_DOWN)</span>
|
492
493
|
</a>
|
493
494
|
</div>
|
@@ -501,12 +502,12 @@ that exp(y) still fits into a float (y <= 709)
|
|
501
502
|
</div>
|
502
503
|
</div>
|
503
504
|
|
504
|
-
<div id="method-
|
505
|
-
<a name="
|
505
|
+
<div id="method-M000136" class="method-detail">
|
506
|
+
<a name="M000136"></a>
|
506
507
|
|
507
508
|
<div class="method-heading">
|
508
|
-
<a href="LongMath.src/
|
509
|
-
onclick="popupCode('LongMath.src/
|
509
|
+
<a href="LongMath.src/M000136.html" target="Code" class="method-signature"
|
510
|
+
onclick="popupCode('LongMath.src/M000136.html');return false;">
|
510
511
|
<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>
|
511
512
|
</a>
|
512
513
|
</div>
|
@@ -521,12 +522,12 @@ if the default settings for the parameters do not work correctly
|
|
521
522
|
</div>
|
522
523
|
</div>
|
523
524
|
|
524
|
-
<div id="method-
|
525
|
-
<a name="
|
525
|
+
<div id="method-M000118" class="method-detail">
|
526
|
+
<a name="M000118"></a>
|
526
527
|
|
527
528
|
<div class="method-heading">
|
528
|
-
<a href="LongMath.src/
|
529
|
-
onclick="popupCode('LongMath.src/
|
529
|
+
<a href="LongMath.src/M000118.html" target="Code" class="method-signature"
|
530
|
+
onclick="popupCode('LongMath.src/M000118.html');return false;">
|
530
531
|
<span class="method-name">split_to_words</span><span class="method-args">(x, word_len = 32)</span>
|
531
532
|
</a>
|
532
533
|
</div>
|
@@ -535,25 +536,25 @@ if the default settings for the parameters do not work correctly
|
|
535
536
|
<p>
|
536
537
|
split number (Integer) x into parts of word_len bits each such that the
|
537
538
|
concatenation of these parts as bit patterns is x (the opposite of <a
|
538
|
-
href="LongMath.html#
|
539
|
+
href="LongMath.html#M000119">merge_from_words</a>)
|
539
540
|
</p>
|
540
541
|
</div>
|
541
542
|
</div>
|
542
543
|
|
543
|
-
<div id="method-
|
544
|
-
<a name="
|
544
|
+
<div id="method-M000130" class="method-detail">
|
545
|
+
<a name="M000130"></a>
|
545
546
|
|
546
547
|
<div class="method-heading">
|
547
|
-
<a href="LongMath.src/
|
548
|
-
onclick="popupCode('LongMath.src/
|
549
|
-
<span class="method-name">
|
548
|
+
<a href="LongMath.src/M000130.html" target="Code" class="method-signature"
|
549
|
+
onclick="popupCode('LongMath.src/M000130.html');return false;">
|
550
|
+
<span class="method-name">sqrt</span><span class="method-args">(x, prec, rounding_mode)</span>
|
550
551
|
</a>
|
551
552
|
</div>
|
552
553
|
|
553
554
|
<div class="method-description">
|
554
555
|
<p>
|
555
|
-
calculate
|
556
|
-
|
556
|
+
calculate approximation of sqrt of a <a
|
557
|
+
href="LongDecimal.html">LongDecimal</a>.
|
557
558
|
</p>
|
558
559
|
</div>
|
559
560
|
</div>
|
@@ -564,6 +565,24 @@ result is rounded to an integer y such that y**2
|
|
564
565
|
<div class="method-heading">
|
565
566
|
<a href="LongMath.src/M000120.html" target="Code" class="method-signature"
|
566
567
|
onclick="popupCode('LongMath.src/M000120.html');return false;">
|
568
|
+
<span class="method-name">sqrtb</span><span class="method-args">(x)</span>
|
569
|
+
</a>
|
570
|
+
</div>
|
571
|
+
|
572
|
+
<div class="method-description">
|
573
|
+
<p>
|
574
|
+
calculate the square root of an integer x using bitwise algorithm the
|
575
|
+
result is rounded to an integer y such that y**2�<=�x�<�(y+1)**2
|
576
|
+
</p>
|
577
|
+
</div>
|
578
|
+
</div>
|
579
|
+
|
580
|
+
<div id="method-M000121" class="method-detail">
|
581
|
+
<a name="M000121"></a>
|
582
|
+
|
583
|
+
<div class="method-heading">
|
584
|
+
<a href="LongMath.src/M000121.html" target="Code" class="method-signature"
|
585
|
+
onclick="popupCode('LongMath.src/M000121.html');return false;">
|
567
586
|
<span class="method-name">sqrtb_with_remainder</span><span class="method-args">(x)</span>
|
568
587
|
</a>
|
569
588
|
</div>
|
@@ -580,12 +599,12 @@ result is rounded to an integer y such that y**2
|
|
580
599
|
</div>
|
581
600
|
</div>
|
582
601
|
|
583
|
-
<div id="method-
|
584
|
-
<a name="
|
602
|
+
<div id="method-M000122" class="method-detail">
|
603
|
+
<a name="M000122"></a>
|
585
604
|
|
586
605
|
<div class="method-heading">
|
587
|
-
<a href="LongMath.src/
|
588
|
-
onclick="popupCode('LongMath.src/
|
606
|
+
<a href="LongMath.src/M000122.html" target="Code" class="method-signature"
|
607
|
+
onclick="popupCode('LongMath.src/M000122.html');return false;">
|
589
608
|
<span class="method-name">sqrtw</span><span class="method-args">(x, n = 16)</span>
|
590
609
|
</a>
|
591
610
|
</div>
|
@@ -601,12 +620,12 @@ integer y such that y**2
|
|
601
620
|
</div>
|
602
621
|
</div>
|
603
622
|
|
604
|
-
<div id="method-
|
605
|
-
<a name="
|
623
|
+
<div id="method-M000123" class="method-detail">
|
624
|
+
<a name="M000123"></a>
|
606
625
|
|
607
626
|
<div class="method-heading">
|
608
|
-
<a href="LongMath.src/
|
609
|
-
onclick="popupCode('LongMath.src/
|
627
|
+
<a href="LongMath.src/M000123.html" target="Code" class="method-signature"
|
628
|
+
onclick="popupCode('LongMath.src/M000123.html');return false;">
|
610
629
|
<span class="method-name">sqrtw_with_remainder</span><span class="method-args">(x, n = 16)</span>
|
611
630
|
</a>
|
612
631
|
</div>
|