long-decimal 0.00.20 → 0.00.21

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. data/README +32 -31
  2. data/Rakefile +1 -1
  3. data/VERSION +1 -1
  4. data/doc/classes/LongDecimal.src/M000088.html +1 -1
  5. data/doc/classes/LongDecimal.src/M000089.html +1 -1
  6. data/doc/classes/LongDecimal.src/M000090.html +1 -1
  7. data/doc/classes/LongDecimal.src/M000091.html +1 -1
  8. data/doc/classes/LongDecimal.src/M000092.html +1 -1
  9. data/doc/classes/LongDecimal.src/M000093.html +1 -1
  10. data/doc/classes/LongDecimal.src/M000096.html +1 -1
  11. data/doc/classes/LongDecimal.src/M000097.html +1 -1
  12. data/doc/classes/LongDecimal.src/M000098.html +1 -1
  13. data/doc/classes/LongDecimal.src/M000099.html +1 -1
  14. data/doc/classes/LongDecimal.src/M000100.html +1 -1
  15. data/doc/classes/LongDecimal.src/M000101.html +1 -1
  16. data/doc/classes/LongDecimalBase.html +53 -53
  17. data/doc/classes/LongDecimalBase.src/M000105.html +4 -4
  18. data/doc/classes/LongDecimalBase.src/M000106.html +4 -4
  19. data/doc/classes/LongDecimalBase.src/M000107.html +4 -4
  20. data/doc/classes/LongDecimalBase.src/M000108.html +4 -4
  21. data/doc/classes/LongDecimalBase.src/M000109.html +4 -4
  22. data/doc/classes/LongDecimalBase.src/M000110.html +4 -9
  23. data/doc/classes/LongDecimalBase.src/M000113.html +9 -5
  24. data/doc/classes/LongDecimalBase.src/M000114.html +5 -4
  25. data/doc/classes/LongDecimalQuot.src/M000003.html +1 -1
  26. data/doc/classes/LongDecimalQuot.src/M000004.html +1 -1
  27. data/doc/classes/LongDecimalQuot.src/M000005.html +1 -1
  28. data/doc/classes/LongDecimalQuot.src/M000006.html +1 -1
  29. data/doc/classes/LongDecimalQuot.src/M000007.html +1 -1
  30. data/doc/classes/LongDecimalQuot.src/M000008.html +1 -1
  31. data/doc/classes/LongDecimalQuot.src/M000009.html +1 -1
  32. data/doc/classes/LongDecimalQuot.src/M000010.html +1 -1
  33. data/doc/classes/LongDecimalQuot.src/M000011.html +1 -1
  34. data/doc/classes/LongDecimalQuot.src/M000012.html +1 -1
  35. data/doc/classes/LongDecimalQuot.src/M000013.html +1 -1
  36. data/doc/classes/LongDecimalQuot.src/M000014.html +1 -1
  37. data/doc/classes/LongDecimalQuot.src/M000015.html +1 -1
  38. data/doc/classes/LongDecimalQuot.src/M000016.html +1 -1
  39. data/doc/classes/LongDecimalQuot.src/M000017.html +1 -1
  40. data/doc/classes/LongDecimalQuot.src/M000018.html +1 -1
  41. data/doc/classes/LongDecimalQuot.src/M000019.html +1 -1
  42. data/doc/classes/LongDecimalQuot.src/M000020.html +1 -1
  43. data/doc/classes/LongDecimalQuot.src/M000021.html +1 -1
  44. data/doc/classes/LongDecimalQuot.src/M000022.html +1 -1
  45. data/doc/classes/LongDecimalQuot.src/M000023.html +1 -1
  46. data/doc/classes/LongDecimalQuot.src/M000024.html +1 -1
  47. data/doc/classes/LongDecimalQuot.src/M000025.html +1 -1
  48. data/doc/classes/LongDecimalQuot.src/M000026.html +1 -1
  49. data/doc/classes/LongDecimalQuot.src/M000027.html +1 -1
  50. data/doc/classes/LongDecimalQuot.src/M000028.html +1 -1
  51. data/doc/classes/LongDecimalQuot.src/M000029.html +1 -1
  52. data/doc/classes/LongDecimalQuot.src/M000032.html +1 -1
  53. data/doc/classes/LongDecimalQuot.src/M000033.html +1 -1
  54. data/doc/classes/LongDecimalRoundingMode/RoundingModeClass.html +10 -10
  55. data/doc/classes/LongMath.html +170 -151
  56. data/doc/classes/LongMath.src/M000116.html +5 -4
  57. data/doc/classes/LongMath.src/M000117.html +4 -4
  58. data/doc/classes/LongMath.src/M000118.html +4 -5
  59. data/doc/classes/LongMath.src/M000119.html +5 -4
  60. data/doc/classes/LongMath.src/M000120.html +4 -18
  61. data/doc/classes/LongMath.src/M000121.html +14 -14
  62. data/doc/classes/LongMath.src/M000122.html +18 -5
  63. data/doc/classes/LongMath.src/M000123.html +5 -29
  64. data/doc/classes/LongMath.src/M000124.html +29 -5
  65. data/doc/classes/LongMath.src/M000125.html +5 -56
  66. data/doc/classes/LongMath.src/M000126.html +55 -19
  67. data/doc/classes/LongMath.src/M000127.html +20 -35
  68. data/doc/classes/LongMath.src/M000128.html +36 -6
  69. data/doc/classes/LongMath.src/M000129.html +6 -33
  70. data/doc/classes/LongMath.src/M000130.html +26 -41
  71. data/doc/classes/LongMath.src/M000131.html +46 -6
  72. data/doc/classes/LongMath.src/M000132.html +8 -4
  73. data/doc/classes/LongMath.src/M000133.html +4 -4
  74. data/doc/classes/LongMath.src/M000134.html +4 -64
  75. data/doc/classes/LongMath.src/M000135.html +59 -38
  76. data/doc/classes/LongMath.src/M000136.html +41 -8
  77. data/doc/classes/LongMath.src/M000137.html +4 -7
  78. data/doc/classes/LongMath.src/M000138.html +4 -20
  79. data/doc/classes/LongMath.src/M000139.html +4 -17
  80. data/doc/classes/LongMath.src/M000140.html +11 -34
  81. data/doc/classes/LongMath.src/M000141.html +14 -199
  82. data/doc/classes/LongMath.src/M000142.html +40 -16
  83. data/doc/classes/LongMath.src/M000143.html +211 -8
  84. data/doc/classes/LongMath.src/M000144.html +16 -41
  85. data/doc/classes/LongMath/CacheKey.html +5 -5
  86. data/doc/classes/Numeric.html +18 -0
  87. data/doc/classes/Numeric.src/M000102.html +1 -1
  88. data/doc/classes/Rational.html +5 -5
  89. data/doc/created.rid +1 -1
  90. data/doc/files/lib/long-decimal_rb.html +2 -2
  91. data/doc/files/lib/long-decimal_rb.src/M000001.html +1 -1
  92. data/doc/files/lib/long-decimal_rb.src/M000002.html +1 -1
  93. data/doc/fr_method_index.html +61 -59
  94. data/lib/long-decimal.rb +173 -80
  95. data/test/testlongdecimal.rb +258 -58
  96. metadata +2 -2
@@ -101,7 +101,7 @@
101
101
  <h3 class="section-bar">Methods</h3>
102
102
 
103
103
  <div class="name-list">
104
- <a href="#M000103">to_ld</a>&nbsp;&nbsp;
104
+ <a href="#M000104">to_ld</a>&nbsp;&nbsp;
105
105
  </div>
106
106
  </div>
107
107
 
@@ -123,12 +123,12 @@
123
123
  <div id="methods">
124
124
  <h3 class="section-bar">Public Instance methods</h3>
125
125
 
126
- <div id="method-M000103" class="method-detail">
127
- <a name="M000103"></a>
126
+ <div id="method-M000104" class="method-detail">
127
+ <a name="M000104"></a>
128
128
 
129
129
  <div class="method-heading">
130
- <a href="Rational.src/M000103.html" target="Code" class="method-signature"
131
- onclick="popupCode('Rational.src/M000103.html');return false;">
130
+ <a href="Rational.src/M000104.html" target="Code" class="method-signature"
131
+ onclick="popupCode('Rational.src/M000104.html');return false;">
132
132
  <span class="method-name">to_ld</span><span class="method-args">(prec = nil, mode = LongDecimal::ROUND_HALF_UP)</span>
133
133
  </a>
134
134
  </div>
data/doc/created.rid CHANGED
@@ -1 +1 @@
1
- Sun Apr 02 18:14:18 CEST 2006
1
+ Thu Apr 06 01:55:52 CEST 2006
@@ -56,7 +56,7 @@
56
56
  </tr>
57
57
  <tr class="top-aligned-row">
58
58
  <td><strong>Last Update:</strong></td>
59
- <td>Sun Apr 02 18:12:26 CEST 2006</td>
59
+ <td>Thu Apr 06 01:55:44 CEST 2006</td>
60
60
  </tr>
61
61
  </table>
62
62
  </div>
@@ -90,7 +90,7 @@ point
90
90
  </p>
91
91
  <p>
92
92
  CVS-ID: $Header: /var/cvs/long-decimal/long-decimal/lib/long-decimal.rb,v
93
- 1.20 2006/04/02 15:52:27 bk1 Exp $ CVS-Label: $Name: PRE_ALPHA_0_20 $
93
+ 1.24 2006/04/05 21:15:52 bk1 Exp $ CVS-Label: $Name: PRE_ALPHA_0_21 $
94
94
  Author: $Author: bk1 $ (Karl Brodowsky)
95
95
  </p>
96
96
 
@@ -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 1710</span>
13
+ <pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line 1679</span>
14
14
  <span class="ruby-keyword kw">def</span> <span class="ruby-constant">LongDecimal</span>(<span class="ruby-identifier">a</span>, <span class="ruby-identifier">b</span> = <span class="ruby-value">0</span>)
15
15
  <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">b</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span> <span class="ruby-operator">&amp;&amp;</span> (<span class="ruby-identifier">a</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">LongDecimal</span>) <span class="ruby-keyword kw">then</span>
16
16
  <span class="ruby-identifier">a</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 1723</span>
13
+ <pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line 1692</span>
14
14
  <span class="ruby-keyword kw">def</span> <span class="ruby-constant">LongDecimalQuot</span>(<span class="ruby-identifier">first</span>, <span class="ruby-identifier">second</span>)
15
15
  <span class="ruby-constant">LongDecimalQuot</span>.<span class="ruby-identifier">new!</span>(<span class="ruby-identifier">first</span>, <span class="ruby-identifier">second</span>)
16
16
  <span class="ruby-keyword kw">end</span></pre>
@@ -20,26 +20,26 @@
20
20
  <div id="index">
21
21
  <h1 class="section-bar">Methods</h1>
22
22
  <div id="index-entries">
23
- <a href="classes/LongDecimal.html#M000074">% (LongDecimal)</a><br />
24
23
  <a href="classes/LongDecimalQuot.html#M000021">% (LongDecimalQuot)</a><br />
24
+ <a href="classes/LongDecimal.html#M000074">% (LongDecimal)</a><br />
25
25
  <a href="classes/LongDecimal.html#M000075">& (LongDecimal)</a><br />
26
- <a href="classes/LongDecimalQuot.html#M000017">* (LongDecimalQuot)</a><br />
27
26
  <a href="classes/LongDecimal.html#M000067">* (LongDecimal)</a><br />
28
- <a href="classes/LongDecimal.html#M000072">** (LongDecimal)</a><br />
27
+ <a href="classes/LongDecimalQuot.html#M000017">* (LongDecimalQuot)</a><br />
29
28
  <a href="classes/LongDecimalQuot.html#M000019">** (LongDecimalQuot)</a><br />
30
- <a href="classes/LongDecimalQuot.html#M000015">+ (LongDecimalQuot)</a><br />
29
+ <a href="classes/LongDecimal.html#M000072">** (LongDecimal)</a><br />
31
30
  <a href="classes/LongDecimal.html#M000065">+ (LongDecimal)</a><br />
32
- <a href="classes/LongDecimalBase.html#M000107">+@ (LongDecimalBase)</a><br />
31
+ <a href="classes/LongDecimalQuot.html#M000015">+ (LongDecimalQuot)</a><br />
32
+ <a href="classes/LongDecimalBase.html#M000108">+@ (LongDecimalBase)</a><br />
33
33
  <a href="classes/LongDecimal.html#M000066">- (LongDecimal)</a><br />
34
34
  <a href="classes/LongDecimalQuot.html#M000016">- (LongDecimalQuot)</a><br />
35
35
  <a href="classes/LongDecimal.html#M000064">-@ (LongDecimal)</a><br />
36
36
  <a href="classes/LongDecimalQuot.html#M000014">-@ (LongDecimalQuot)</a><br />
37
- <a href="classes/LongDecimal.html#M000071">/ (LongDecimal)</a><br />
38
37
  <a href="classes/LongDecimalQuot.html#M000018">/ (LongDecimalQuot)</a><br />
38
+ <a href="classes/LongDecimal.html#M000071">/ (LongDecimal)</a><br />
39
39
  <a href="classes/LongDecimal.html#M000079"><< (LongDecimal)</a><br />
40
- <a href="classes/LongMath/CacheKey.html#M000145"><=> (LongMath::CacheKey)</a><br />
41
- <a href="classes/LongDecimalRoundingMode/RoundingModeClass.html#M000146"><=> (LongDecimalRoundingMode::RoundingModeClass)</a><br />
42
- <a href="classes/LongDecimalBase.html#M000112"><=> (LongDecimalBase)</a><br />
40
+ <a href="classes/LongDecimalRoundingMode/RoundingModeClass.html#M000148"><=> (LongDecimalRoundingMode::RoundingModeClass)</a><br />
41
+ <a href="classes/LongMath/CacheKey.html#M000147"><=> (LongMath::CacheKey)</a><br />
42
+ <a href="classes/LongDecimalBase.html#M000113"><=> (LongDecimalBase)</a><br />
43
43
  <a href="classes/LongDecimal.html#M000096">== (LongDecimal)</a><br />
44
44
  <a href="classes/LongDecimalQuot.html#M000025">== (LongDecimalQuot)</a><br />
45
45
  <a href="classes/LongDecimal.html#M000097">=== (LongDecimal)</a><br />
@@ -48,114 +48,116 @@
48
48
  <a href="files/lib/long-decimal_rb.html#M000002">LongDecimalQuot (lib/long-decimal.rb)</a><br />
49
49
  <a href="classes/LongDecimal.html#M000081">[] (LongDecimal)</a><br />
50
50
  <a href="classes/LongDecimal.html#M000077">^ (LongDecimal)</a><br />
51
- <a href="classes/LongDecimalQuot.html#M000022">abs (LongDecimalQuot)</a><br />
52
51
  <a href="classes/LongDecimal.html#M000090">abs (LongDecimal)</a><br />
53
- <a href="classes/LongDecimalBase.html#M000111">abs2 (LongDecimalBase)</a><br />
52
+ <a href="classes/LongDecimalQuot.html#M000022">abs (LongDecimalQuot)</a><br />
53
+ <a href="classes/LongDecimalBase.html#M000112">abs2 (LongDecimalBase)</a><br />
54
54
  <a href="classes/LongDecimal.html#M000057">anti_equalize_scale (LongDecimal)</a><br />
55
- <a href="classes/LongMath.html#M000142">calc_iprec_for_power (LongMath)</a><br />
56
- <a href="classes/LongMath.html#M000116">check_is_int (LongMath)</a><br />
57
- <a href="classes/LongMath.html#M000117">check_is_ld (LongMath)</a><br />
58
- <a href="classes/LongMath.html#M000119">check_is_mode (LongMath)</a><br />
59
- <a href="classes/LongMath.html#M000118">check_is_prec (LongMath)</a><br />
60
- <a href="classes/LongMath.html#M000115">check_word_len (LongMath)</a><br />
55
+ <a href="classes/LongMath.html#M000144">calc_iprec_for_power (LongMath)</a><br />
56
+ <a href="classes/LongMath.html#M000117">check_is_int (LongMath)</a><br />
57
+ <a href="classes/LongMath.html#M000118">check_is_ld (LongMath)</a><br />
58
+ <a href="classes/LongMath.html#M000120">check_is_mode (LongMath)</a><br />
59
+ <a href="classes/LongMath.html#M000119">check_is_prec (LongMath)</a><br />
60
+ <a href="classes/LongMath.html#M000116">check_word_len (LongMath)</a><br />
61
61
  <a href="classes/LongDecimal.html#M000091">coerce (LongDecimal)</a><br />
62
62
  <a href="classes/LongDecimalQuot.html#M000024">coerce (LongDecimalQuot)</a><br />
63
- <a href="classes/LongDecimalBase.html#M000106">dec (LongDecimalBase)</a><br />
63
+ <a href="classes/LongDecimalBase.html#M000107">dec (LongDecimalBase)</a><br />
64
64
  <a href="classes/LongDecimal.html#M000062">dec! (LongDecimal)</a><br />
65
65
  <a href="classes/LongDecimalQuot.html#M000013">dec! (LongDecimalQuot)</a><br />
66
- <a href="classes/LongDecimalQuot.html#M000006">denominator (LongDecimalQuot)</a><br />
67
66
  <a href="classes/LongDecimal.html#M000052">denominator (LongDecimal)</a><br />
67
+ <a href="classes/LongDecimalQuot.html#M000006">denominator (LongDecimalQuot)</a><br />
68
68
  <a href="classes/LongDecimal.html#M000068">divide (LongDecimal)</a><br />
69
69
  <a href="classes/LongDecimal.html#M000069">divide_s (LongDecimal)</a><br />
70
70
  <a href="classes/LongDecimal.html#M000073">divmod (LongDecimal)</a><br />
71
71
  <a href="classes/LongDecimalQuot.html#M000020">divmod (LongDecimalQuot)</a><br />
72
72
  <a href="classes/LongDecimal.html#M000056">equalize_scale (LongDecimal)</a><br />
73
- <a href="classes/LongMath.html#M000131">exp (LongMath)</a><br />
74
- <a href="classes/LongMath.html#M000133">exp10 (LongMath)</a><br />
75
- <a href="classes/LongMath.html#M000132">exp2 (LongMath)</a><br />
76
- <a href="classes/LongMath.html#M000134">exp_internal (LongMath)</a><br />
77
- <a href="classes/LongMath.html#M000135">exp_raw (LongMath)</a><br />
78
- <a href="classes/LongMath.html#M000126">gcd_with_high_power (LongMath)</a><br />
73
+ <a href="classes/LongMath.html#M000132">exp (LongMath)</a><br />
74
+ <a href="classes/LongMath.html#M000134">exp10 (LongMath)</a><br />
75
+ <a href="classes/LongMath.html#M000133">exp2 (LongMath)</a><br />
76
+ <a href="classes/LongMath.html#M000135">exp_internal (LongMath)</a><br />
77
+ <a href="classes/LongMath.html#M000136">exp_raw (LongMath)</a><br />
78
+ <a href="classes/LongMath.html#M000127">gcd_with_high_power (LongMath)</a><br />
79
79
  <a href="classes/LongDecimalQuot.html#M000032">hash (LongDecimalQuot)</a><br />
80
+ <a href="classes/LongDecimalRoundingMode/RoundingModeClass.html#M000149">hash (LongDecimalRoundingMode::RoundingModeClass)</a><br />
80
81
  <a href="classes/LongDecimal.html#M000100">hash (LongDecimal)</a><br />
81
- <a href="classes/LongDecimalRoundingMode/RoundingModeClass.html#M000147">hash (LongDecimalRoundingMode::RoundingModeClass)</a><br />
82
- <a href="classes/LongDecimalBase.html#M000105">inc (LongDecimalBase)</a><br />
82
+ <a href="classes/LongDecimalBase.html#M000106">inc (LongDecimalBase)</a><br />
83
83
  <a href="classes/LongDecimal.html#M000061">inc! (LongDecimal)</a><br />
84
84
  <a href="classes/LongDecimalQuot.html#M000012">inc! (LongDecimalQuot)</a><br />
85
- <a href="classes/LongDecimalQuot.html#M000033">inspect (LongDecimalQuot)</a><br />
86
85
  <a href="classes/LongDecimal.html#M000101">inspect (LongDecimal)</a><br />
86
+ <a href="classes/LongDecimalQuot.html#M000033">inspect (LongDecimalQuot)</a><br />
87
87
  <a href="classes/LongDecimal.html#M000055">int_digits10 (LongDecimal)</a><br />
88
- <a href="classes/LongMath.html#M000129">int_digits10 (LongMath)</a><br />
88
+ <a href="classes/LongMath.html#M000130">int_digits10 (LongMath)</a><br />
89
89
  <a href="classes/LongDecimal.html#M000053">int_digits2 (LongDecimal)</a><br />
90
- <a href="classes/LongDecimalBase.html#M000110">inverse (LongDecimalBase)</a><br />
90
+ <a href="classes/LongDecimalBase.html#M000111">inverse (LongDecimalBase)</a><br />
91
91
  <a href="classes/LongDecimalQuot.html#M000028">is_int? (LongDecimalQuot)</a><br />
92
92
  <a href="classes/LongDecimal.html#M000092">is_int? (LongDecimal)</a><br />
93
- <a href="classes/LongMath.html#M000137">log (LongMath)</a><br />
94
- <a href="classes/LongMath.html#M000138">log10 (LongMath)</a><br />
95
- <a href="classes/LongMath.html#M000139">log2 (LongMath)</a><br />
96
- <a href="classes/LongMath.html#M000140">log_internal (LongMath)</a><br />
97
- <a href="classes/LongMath.html#M000141">log_raw (LongMath)</a><br />
98
- <a href="classes/LongMath.html#M000121">merge_from_words (LongMath)</a><br />
93
+ <a href="classes/LongMath.html#M000139">log (LongMath)</a><br />
94
+ <a href="classes/LongMath.html#M000140">log10 (LongMath)</a><br />
95
+ <a href="classes/LongMath.html#M000141">log2 (LongMath)</a><br />
96
+ <a href="classes/LongMath.html#M000142">log_internal (LongMath)</a><br />
97
+ <a href="classes/LongMath.html#M000143">log_raw (LongMath)</a><br />
98
+ <a href="classes/LongMath.html#M000122">merge_from_words (LongMath)</a><br />
99
99
  <a href="classes/LongDecimal.html#M000039">minus_one! (LongDecimal)</a><br />
100
100
  <a href="classes/LongDecimal.html#M000083">move_point_left (LongDecimal)</a><br />
101
101
  <a href="classes/LongDecimal.html#M000085">move_point_left_int (LongDecimal)</a><br />
102
102
  <a href="classes/LongDecimal.html#M000084">move_point_right (LongDecimal)</a><br />
103
103
  <a href="classes/LongDecimal.html#M000086">move_point_right_int (LongDecimal)</a><br />
104
- <a href="classes/LongMath.html#M000128">multiplicity_of_10 (LongMath)</a><br />
105
- <a href="classes/LongMath.html#M000127">multiplicity_of_factor (LongMath)</a><br />
106
- <a href="classes/LongDecimalQuot.html#M000004">new (LongDecimalQuot)</a><br />
104
+ <a href="classes/LongMath.html#M000129">multiplicity_of_10 (LongMath)</a><br />
105
+ <a href="classes/LongMath.html#M000128">multiplicity_of_factor (LongMath)</a><br />
107
106
  <a href="classes/LongDecimal.html#M000041">new (LongDecimal)</a><br />
107
+ <a href="classes/LongDecimalQuot.html#M000004">new (LongDecimalQuot)</a><br />
108
108
  <a href="classes/LongDecimal.html#M000034">new! (LongDecimal)</a><br />
109
109
  <a href="classes/LongDecimalQuot.html#M000003">new! (LongDecimalQuot)</a><br />
110
110
  <a href="classes/LongDecimal.html#M000059">next (LongDecimal)</a><br />
111
111
  <a href="classes/LongDecimalQuot.html#M000005">numerator (LongDecimalQuot)</a><br />
112
112
  <a href="classes/LongDecimal.html#M000036">one! (LongDecimal)</a><br />
113
- <a href="classes/LongDecimalQuot.html#M000027">one? (LongDecimalQuot)</a><br />
114
113
  <a href="classes/LongDecimal.html#M000099">one? (LongDecimal)</a><br />
115
- <a href="classes/LongMath.html#M000130">pi (LongMath)</a><br />
116
- <a href="classes/LongMath.html#M000143">power (LongMath)</a><br />
117
- <a href="classes/LongMath.html#M000144">power_internal (LongMath)</a><br />
114
+ <a href="classes/LongDecimalQuot.html#M000027">one? (LongDecimalQuot)</a><br />
115
+ <a href="classes/Numeric.html#M000103">one? (Numeric)</a><br />
116
+ <a href="classes/LongMath.html#M000131">pi (LongMath)</a><br />
117
+ <a href="classes/LongMath.html#M000145">power (LongMath)</a><br />
118
+ <a href="classes/LongMath.html#M000146">power_internal (LongMath)</a><br />
118
119
  <a href="classes/LongDecimal.html#M000040">power_of_ten! (LongDecimal)</a><br />
119
120
  <a href="classes/LongDecimal.html#M000060">pred (LongDecimal)</a><br />
120
121
  <a href="classes/LongDecimal.html#M000070">rdiv (LongDecimal)</a><br />
121
- <a href="classes/LongDecimalBase.html#M000109">reciprocal (LongDecimalBase)</a><br />
122
- <a href="classes/LongDecimalQuot.html#M000023">round_to_scale (LongDecimalQuot)</a><br />
122
+ <a href="classes/LongDecimalBase.html#M000110">reciprocal (LongDecimalBase)</a><br />
123
123
  <a href="classes/LongDecimal.html#M000044">round_to_scale (LongDecimal)</a><br />
124
+ <a href="classes/LongDecimalQuot.html#M000023">round_to_scale (LongDecimalQuot)</a><br />
124
125
  <a href="classes/LongDecimal.html#M000043">round_trailing_zeros (LongDecimal)</a><br />
125
126
  <a href="classes/LongDecimal.html#M000042">scale= (LongDecimal)</a><br />
126
- <a href="classes/LongDecimalBase.html#M000114">scale_equal (LongDecimalBase)</a><br />
127
- <a href="classes/LongDecimalBase.html#M000113">scale_ufo (LongDecimalBase)</a><br />
128
- <a href="classes/LongDecimalQuot.html#M000029">sgn (LongDecimalQuot)</a><br />
127
+ <a href="classes/LongDecimalBase.html#M000115">scale_equal (LongDecimalBase)</a><br />
128
+ <a href="classes/LongDecimalBase.html#M000114">scale_ufo (LongDecimalBase)</a><br />
129
129
  <a href="classes/LongDecimal.html#M000093">sgn (LongDecimal)</a><br />
130
+ <a href="classes/LongDecimalQuot.html#M000029">sgn (LongDecimalQuot)</a><br />
130
131
  <a href="classes/LongDecimal.html#M000095">sign (LongDecimal)</a><br />
131
132
  <a href="classes/LongDecimalQuot.html#M000031">sign (LongDecimalQuot)</a><br />
132
133
  <a href="classes/LongDecimal.html#M000094">signum (LongDecimal)</a><br />
133
134
  <a href="classes/LongDecimalQuot.html#M000030">signum (LongDecimalQuot)</a><br />
134
135
  <a href="classes/LongDecimal.html#M000054">sint_digits10 (LongDecimal)</a><br />
135
136
  <a href="classes/LongDecimal.html#M000082">size (LongDecimal)</a><br />
136
- <a href="classes/LongMath.html#M000120">split_to_words (LongMath)</a><br />
137
- <a href="classes/LongMath.html#M000136">sqrt (LongMath)</a><br />
137
+ <a href="classes/LongMath.html#M000121">split_to_words (LongMath)</a><br />
138
+ <a href="classes/LongMath.html#M000137">sqrt (LongMath)</a><br />
138
139
  <a href="classes/LongDecimal.html#M000088">sqrt (LongDecimal)</a><br />
140
+ <a href="classes/LongMath.html#M000138">sqrt_with_remainder (LongMath)</a><br />
139
141
  <a href="classes/LongDecimal.html#M000089">sqrt_with_remainder (LongDecimal)</a><br />
140
- <a href="classes/LongMath.html#M000122">sqrtb (LongMath)</a><br />
141
- <a href="classes/LongMath.html#M000123">sqrtb_with_remainder (LongMath)</a><br />
142
- <a href="classes/LongMath.html#M000124">sqrtw (LongMath)</a><br />
143
- <a href="classes/LongMath.html#M000125">sqrtw_with_remainder (LongMath)</a><br />
142
+ <a href="classes/LongMath.html#M000123">sqrtb (LongMath)</a><br />
143
+ <a href="classes/LongMath.html#M000124">sqrtb_with_remainder (LongMath)</a><br />
144
+ <a href="classes/LongMath.html#M000125">sqrtw (LongMath)</a><br />
145
+ <a href="classes/LongMath.html#M000126">sqrtw_with_remainder (LongMath)</a><br />
146
+ <a href="classes/LongDecimalBase.html#M000109">square (LongDecimalBase)</a><br />
144
147
  <a href="classes/LongDecimal.html#M000087">square (LongDecimal)</a><br />
145
- <a href="classes/LongDecimalBase.html#M000108">square (LongDecimalBase)</a><br />
146
148
  <a href="classes/LongDecimal.html#M000058">succ (LongDecimal)</a><br />
147
149
  <a href="classes/LongDecimal.html#M000038">ten! (LongDecimal)</a><br />
148
- <a href="classes/LongDecimalQuot.html#M000009">to_bd (LongDecimalQuot)</a><br />
149
150
  <a href="classes/LongDecimal.html#M000051">to_bd (LongDecimal)</a><br />
151
+ <a href="classes/LongDecimalQuot.html#M000009">to_bd (LongDecimalQuot)</a><br />
150
152
  <a href="classes/LongDecimal.html#M000048">to_f (LongDecimal)</a><br />
151
153
  <a href="classes/LongDecimalQuot.html#M000008">to_f (LongDecimalQuot)</a><br />
152
154
  <a href="classes/LongDecimalQuot.html#M000010">to_i (LongDecimalQuot)</a><br />
153
155
  <a href="classes/LongDecimal.html#M000049">to_i (LongDecimal)</a><br />
154
- <a href="classes/Rational.html#M000103">to_ld (Rational)</a><br />
155
- <a href="classes/LongDecimal.html#M000050">to_ld (LongDecimal)</a><br />
156
156
  <a href="classes/LongDecimalQuot.html#M000011">to_ld (LongDecimalQuot)</a><br />
157
+ <a href="classes/LongDecimal.html#M000050">to_ld (LongDecimal)</a><br />
157
158
  <a href="classes/Numeric.html#M000102">to_ld (Numeric)</a><br />
158
- <a href="classes/LongDecimalBase.html#M000104">to_r (LongDecimalBase)</a><br />
159
+ <a href="classes/Rational.html#M000104">to_ld (Rational)</a><br />
160
+ <a href="classes/LongDecimalBase.html#M000105">to_r (LongDecimalBase)</a><br />
159
161
  <a href="classes/LongDecimalQuot.html#M000007">to_s (LongDecimalQuot)</a><br />
160
162
  <a href="classes/LongDecimal.html#M000045">to_s (LongDecimal)</a><br />
161
163
  <a href="classes/LongDecimal.html#M000046">to_s_10 (LongDecimal)</a><br />
data/lib/long-decimal.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  #
2
2
  # long-decimal.rb -- Arbitrary precision decimals with fixed decimal point
3
3
  #
4
- # CVS-ID: $Header: /var/cvs/long-decimal/long-decimal/lib/long-decimal.rb,v 1.20 2006/04/02 15:52:27 bk1 Exp $
5
- # CVS-Label: $Name: PRE_ALPHA_0_20 $
4
+ # CVS-ID: $Header: /var/cvs/long-decimal/long-decimal/lib/long-decimal.rb,v 1.24 2006/04/05 21:15:52 bk1 Exp $
5
+ # CVS-Label: $Name: PRE_ALPHA_0_21 $
6
6
  # Author: $Author: bk1 $ (Karl Brodowsky)
7
7
  #
8
8
  require "complex"
@@ -61,7 +61,7 @@ end # LongDecimalRoundingMode
61
61
  # common base class for LongDecimal and LongDecimalQuot
62
62
  #
63
63
  class LongDecimalBase < Numeric
64
- @RCS_ID='-$Id: long-decimal.rb,v 1.20 2006/04/02 15:52:27 bk1 Exp $-'
64
+ @RCS_ID='-$Id: long-decimal.rb,v 1.24 2006/04/05 21:15:52 bk1 Exp $-'
65
65
 
66
66
  include LongDecimalRoundingMode
67
67
 
@@ -164,7 +164,7 @@ end # class LongDecimalBase
164
164
  # digits and the other one the position of the decimal point.
165
165
  #
166
166
  class LongDecimal < LongDecimalBase
167
- @RCS_ID='-$Id: long-decimal.rb,v 1.20 2006/04/02 15:52:27 bk1 Exp $-'
167
+ @RCS_ID='-$Id: long-decimal.rb,v 1.24 2006/04/05 21:15:52 bk1 Exp $-'
168
168
 
169
169
  # MINUS_ONE = LongDecimal(-1)
170
170
  # ZERO = LongDecimal(0)
@@ -1034,7 +1034,7 @@ class LongDecimal < LongDecimalBase
1034
1034
  # use rounding_mode if the result is not exact
1035
1035
  #
1036
1036
  def sqrt(new_scale, rounding_mode)
1037
- sqrt_internal(new_scale, rounding_mode, false)
1037
+ LongMath.sqrt(self, new_scale, rounding_mode)
1038
1038
  end
1039
1039
 
1040
1040
  #
@@ -1044,40 +1044,9 @@ class LongDecimal < LongDecimalBase
1044
1044
  # new_scale of digits after the decimal point
1045
1045
  #
1046
1046
  def sqrt_with_remainder(new_scale)
1047
- sqrt_internal(new_scale, ROUND_DOWN, true)
1047
+ LongMath.sqrt_with_remainder(self, new_scale)
1048
1048
  end
1049
1049
 
1050
-
1051
- #
1052
- # internal helper method for calculationg sqrt and sqrt_with_remainder
1053
- #
1054
- def sqrt_internal(new_scale, rounding_mode, with_rem)
1055
- raise TypeError, "new_scale #{new_scale.inspect} must be integer" unless new_scale.kind_of? Integer
1056
- raise TypeError, "new_scale #{new_scale.inspect} must be >= 0" unless new_scale >= 0
1057
- raise TypeError, "mode #{mode.inspect} must be legal rounding mode" unless rounding_mode.kind_of? RoundingModeClass
1058
-
1059
- new_scale1 = new_scale
1060
- unless (with_rem) then
1061
- new_scale1 += 1
1062
- end
1063
- old_scale = (new_scale1 << 1)
1064
- x = round_to_scale(old_scale, rounding_mode)
1065
- root, rem = LongMath.sqrtw_with_remainder(x.int_val)
1066
- y = LongDecimal(root, new_scale1)
1067
- if (with_rem) then
1068
- r = LongDecimal(rem, old_scale)
1069
- return [ y, r ]
1070
- else
1071
- if ((rounding_mode == ROUND_HALF_EVEN || rounding_mode == ROUND_HALF_DOWN) && rem > 0) then
1072
- rounding_mode = ROUND_HALF_UP
1073
- end
1074
- y = y.round_to_scale(new_scale, rounding_mode)
1075
- return y
1076
- end
1077
- end
1078
-
1079
- private :sqrt_internal
1080
-
1081
1050
  #
1082
1051
  # Absolute value
1083
1052
  #
@@ -1228,7 +1197,7 @@ end # LongDecimal
1228
1197
  #
1229
1198
  class LongDecimalQuot < LongDecimalBase
1230
1199
 
1231
- @RCS_ID='-$Id: long-decimal.rb,v 1.20 2006/04/02 15:52:27 bk1 Exp $-'
1200
+ @RCS_ID='-$Id: long-decimal.rb,v 1.24 2006/04/05 21:15:52 bk1 Exp $-'
1232
1201
 
1233
1202
  #
1234
1203
  # constructor
@@ -1741,6 +1710,13 @@ class Numeric
1741
1710
  end
1742
1711
  end
1743
1712
 
1713
+ #
1714
+ # test if 1 (like zero?)
1715
+ #
1716
+ def one?
1717
+ (self - 1).zero?
1718
+ end
1719
+
1744
1720
  end # Numeric
1745
1721
 
1746
1722
  class Rational
@@ -1852,6 +1828,14 @@ module LongMath
1852
1828
  return val
1853
1829
  end
1854
1830
 
1831
+ #
1832
+ # helper method for the check of type
1833
+ #
1834
+ def LongMath.check_cacheable(x, s="x")
1835
+ raise TypeError, "#{s}=#{x} must be LongDecimal or Array of LongDecimal" unless (x.kind_of? LongDecimal) || (x.kind_of? Array) && (x[0].kind_of? LongDecimal)
1836
+ end
1837
+
1838
+
1855
1839
  #
1856
1840
  # store new value in cache, if it provides an improvement of
1857
1841
  # precision
@@ -1861,9 +1845,9 @@ module LongMath
1861
1845
  oval = @@cache[key]
1862
1846
  # puts("set key=#{key}\noval=#{oval}\nval=#{val}\n")
1863
1847
  unless (oval.nil?)
1864
- raise TypeError, "must be LongDecimal" unless (val.kind_of? LongDecimal) && (oval.kind_of? LongDecimal)
1865
- r = val.scale_ufo(oval)
1866
- if (r <= 0)
1848
+ check_cacheable(val, "val")
1849
+ check_cacheable(oval, "oval")
1850
+ if (val.scale <= oval.scale)
1867
1851
  return
1868
1852
  end
1869
1853
  end
@@ -2029,6 +2013,7 @@ module LongMath
2029
2013
  def LongMath.sqrtw_with_remainder(x, n = 16)
2030
2014
  check_is_int(x, "x")
2031
2015
  check_is_int(n, "n")
2016
+
2032
2017
  n2 = n<<1
2033
2018
  n1 = n+1
2034
2019
  check_word_len(n2, "2*n")
@@ -2337,7 +2322,7 @@ module LongMath
2337
2322
  # not work correctly
2338
2323
  #
2339
2324
  def LongMath.exp_internal(x, prec = nil, final_mode = LongDecimal::ROUND_HALF_DOWN, j = nil, k = nil, iprec = nil, mode = LongDecimal::ROUND_HALF_DOWN, cache_result = true)
2340
- # check_is_ld(x, "x")
2325
+
2341
2326
  if (prec == nil) then
2342
2327
  if (x.kind_of? LongDecimalBase)
2343
2328
  prec = x.scale
@@ -2386,7 +2371,7 @@ module LongMath
2386
2371
  check_is_prec(iprec, "iprec")
2387
2372
 
2388
2373
  # we only cache exp(1)
2389
- cache_key = get_cache_key("exp", x, mode, [1])
2374
+ cache_key = get_cache_key("exp", x, mode, [1, 10, 100, MAX_EXP_ABLE.to_i])
2390
2375
  y_k = get_cached(cache_key, x, iprec)
2391
2376
 
2392
2377
  if (y_k.nil?) then
@@ -2451,15 +2436,69 @@ module LongMath
2451
2436
  # calculate approximation of sqrt of a LongDecimal.
2452
2437
  #
2453
2438
  def LongMath.sqrt(x, prec, mode = LongDecimal::ROUND_HALF_DOWN)
2454
- # check_is_ld(x, "x")
2439
+ LongMath.sqrt_internal(x, prec, mode, false)
2440
+ end
2441
+
2442
+ #
2443
+ # calculate approximation of sqrt of a LongDecimal with remainder
2444
+ #
2445
+ def LongMath.sqrt_with_remainder(x, prec)
2446
+ LongMath.sqrt_internal(x, prec, ROUND_DOWN, true)
2447
+ end
2448
+
2449
+ private
2450
+
2451
+ #
2452
+ # internal helper method for calculationg sqrt and sqrt_with_remainder
2453
+ #
2454
+ def LongMath.sqrt_internal(x, prec, mode, with_rem, cache_result = true)
2455
2455
  check_is_prec(prec, "prec")
2456
2456
  check_is_mode(mode, "mode")
2457
2457
  unless (x.kind_of? LongDecimal)
2458
- x = x.to_ld(2*(prec+1), mode)
2458
+ x = x.to_ld(2 * (prec+1), mode)
2459
+ end
2460
+ prec1 = prec
2461
+ unless (with_rem) then
2462
+ prec1 += 1
2463
+ end
2464
+ cache_key = nil
2465
+ unless (with_rem)
2466
+ cache_key = get_cache_key("sqrt", x, mode, [2, 3, 5, 6, 7, 8, 10])
2467
+ y_arr = get_cached(cache_key, x, prec)
2468
+ end
2469
+ if (y_arr.nil?) then
2470
+ y_arr = sqrt_raw(x, prec1, mode)
2471
+ def y_arr.scale
2472
+ self[0].scale
2473
+ end
2474
+ set_cached(cache_key, y_arr) if cache_result
2475
+ end
2476
+ if (with_rem) then
2477
+ return y_arr
2478
+ else
2479
+ y, r = y_arr
2480
+ if ((mode == ROUND_HALF_EVEN || mode == ROUND_HALF_DOWN) && r > 0) then
2481
+ mode = ROUND_HALF_UP
2482
+ end
2483
+ y = y.round_to_scale(prec, mode)
2484
+ return y
2459
2485
  end
2460
- x.sqrt(prec, mode)
2461
2486
  end
2462
2487
 
2488
+ #
2489
+ # calculate sqrt with remainder uncached
2490
+ #
2491
+ def LongMath.sqrt_raw(x, new_scale1, rounding_mode)
2492
+ old_scale = (new_scale1 << 1)
2493
+ x = x.round_to_scale(old_scale, rounding_mode)
2494
+ root, rem = LongMath.sqrtw_with_remainder(x.int_val)
2495
+ y = LongDecimal(root, new_scale1)
2496
+ r = LongDecimal(rem, old_scale)
2497
+ return [y, r]
2498
+ end
2499
+
2500
+ public
2501
+
2463
2502
  #
2464
2503
  # calculate the natural logarithm function of x to the given precision as
2465
2504
  # LongDecimal.
@@ -2576,51 +2615,97 @@ module LongMath
2576
2615
  #
2577
2616
  def LongMath.log_raw(x, prec, iprec, mode)
2578
2617
 
2618
+ # t0 = Time.new
2619
+ # puts("log_raw start")
2620
+
2621
+ # we have to rely on iprec being at least 10
2622
+ raise TypeError, "iprec=#{iprec} out of range" unless (iprec.kind_of? Fixnum) && iprec >= 10
2623
+
2579
2624
  # dprec = [ iprec - 1, (prec + 1) << 1 ].min
2625
+ # dprec >= 9
2580
2626
  dprec = iprec - 1
2581
2627
 
2628
+ # result is stored in y
2582
2629
  y = 0
2630
+ # sign of result
2583
2631
  s = 1
2632
+ # make sure x is >= 1
2584
2633
  if (x < 1) then
2585
2634
  x = (1 / x).round_to_scale(iprec, mode)
2586
2635
  s = -1
2587
2636
  end
2637
+ # puts("log_raw prepared t=#{Time.new-t0}")
2638
+
2639
+ # number that are beyond the usual range of Float need to be
2640
+ # handled specially to reduce to something expressable as Float
2588
2641
  exp_part = 0
2589
2642
  estimate = 0
2590
- while (x > MAX_FLOATABLE) do
2591
- if (exp_part == 0) then
2592
- estimate = MAX_EXP_ABLE.to_ld
2593
- exp_part = exp(estimate, iprec)
2594
- end
2595
- x = (x / exp_part).round_to_scale(iprec, mode)
2596
- if (s < 0) then
2597
- y -= estimate
2598
- else
2599
- y += estimate
2600
- end
2601
- end
2602
-
2603
- delta = LongDecimal(1, 3)
2604
- while (x - 1).abs > delta do
2605
- xf = x.to_f
2606
- mlx = Math.log(xf)
2607
- estimate = mlx.to_ld(20, mode)
2608
- exp_part = exp(estimate, iprec << 1)
2609
- x = (x / exp_part).round_to_scale(iprec, mode)
2610
-
2611
- if (s < 0) then
2612
- y -= estimate
2613
- else
2614
- y += estimate
2643
+ # while (x > MAX_FLOATABLE) do
2644
+ # if (exp_part == 0) then
2645
+ # estimate = MAX_EXP_ABLE.to_i.to_ld
2646
+ # exp_part = exp(estimate, iprec)
2647
+ # end
2648
+ # x = (x / exp_part).round_to_scale(iprec, mode)
2649
+ # if (s < 0) then
2650
+ # y -= estimate
2651
+ # else
2652
+ # y += estimate
2653
+ # end
2654
+ # end
2655
+ exp_keys = [ MAX_EXP_ABLE.to_i, 100, 10, 1 ]
2656
+ exp_keys.each do |exp_key|
2657
+ exp_val = exp(exp_key, iprec)
2658
+ while (x > exp_val) do
2659
+ x = (x / exp_val).round_to_scale(iprec, mode)
2660
+ if (s < 0) then
2661
+ y -= exp_key
2662
+ else
2663
+ y += exp_key
2664
+ end
2615
2665
  end
2616
2666
  end
2667
+ # puts("log_raw divided t=#{Time.new-t0}")
2668
+
2669
+ # # make sure x is close enough to 1 in order to ensure good
2670
+ # # convergence of the Taylor-series
2671
+ # s2 = s
2672
+ # delta = LongDecimal(1, 3)
2673
+ # while (x - 1).abs > delta do
2674
+ # xf = x.to_f
2675
+ # mlx = Math.log(xf)
2676
+ # estimate = mlx.to_ld(20, LongDecimal::ROUND_DOWN)
2677
+ # exp_part = exp(estimate, (1.01 * iprec).ceil)
2678
+ # # exp_part = exp(estimate, iprec << 1)
2679
+ # xq = (x / exp_part)
2680
+ # if (xq < 1)
2681
+ # xq = 1/xq
2682
+ # s = -s
2683
+ # end
2684
+ # x = xq.round_to_scale(iprec, mode)
2685
+ # if (x < 1)
2686
+ # puts("x=#{x} < 1 est=#{estimate} part=#{exp_part} s=#{s} s2=#{s2}\n")
2687
+ # end
2688
+
2689
+ # # add/subtract to y what we have already found
2690
+ # if (s2 < 0) then
2691
+ # y -= estimate
2692
+ # else
2693
+ # y += estimate
2694
+ # end
2695
+ # end
2617
2696
 
2618
2697
  factor = 1
2698
+ sprec = (iprec * 1.5).round
2619
2699
  # delta = LongDecimal(1, (iprec.to_f**(1/3)).round)
2620
- # while (x - 1).abs > delta do
2621
- # x = sqrt(x)
2622
- # factor *= 2
2623
- # end
2700
+ # delta = LongDecimal(1, (iprec.to_f**0.3).round)
2701
+ delta = LongDecimal(1, (iprec.to_f**0.45).round)
2702
+ # delta = LongDecimal(1, LongMath.sqrtw(iprec))
2703
+ # delta = LongDecimal(1, LongMath.sqrtw(LongMath.sqrtw(iprec+1)+1))
2704
+ while (x - 1).abs > delta do
2705
+ x = LongMath.sqrt(x, sprec, mode)
2706
+ factor *= 2
2707
+ end
2708
+ # puts("log_raw rooted t=#{Time.new-t0}")
2624
2709
 
2625
2710
  sum = 0
2626
2711
  z = 1 - x
@@ -2634,8 +2719,10 @@ module LongMath
2634
2719
  sum += d
2635
2720
 
2636
2721
  end
2722
+ # puts("log_raw summed t=#{Time.new-t0}")
2637
2723
 
2638
2724
  y -= ((s * factor) * sum).round_to_scale(iprec, mode)
2725
+ # puts("log_raw done t=#{Time.new-t0}")
2639
2726
  return y
2640
2727
  end
2641
2728
 
@@ -2671,18 +2758,24 @@ module LongMath
2671
2758
  # fits into a float (y <= 709)
2672
2759
  #
2673
2760
  def LongMath.power(x, y, prec, mode = LongDecimal::ROUND_HALF_DOWN)
2674
- # check_is_ld(x, "x")
2675
- # check_is_ld(y, "y")
2676
- raise TypeError, "y=#{y.inspect} must not be greater #{MAX_EXP_ABLE}" unless y <= MAX_EXP_ABLE
2677
- raise TypeError, "x=#{x.inspect} must not be greater #{MAX_FLOATABLE}" unless x <= MAX_FLOATABLE
2678
- raise TypeError, "x=#{x.inspect} must not positive" unless x > 0
2761
+
2762
+ raise TypeError, "x=#{x} must be numeric" unless x.kind_of? Numeric
2763
+ raise TypeError, "y=#{y} must be numeric" unless y.kind_of? Numeric
2764
+ # raise TypeError, "y=#{y.inspect} must not be greater #{MAX_EXP_ABLE}" unless y <= MAX_EXP_ABLE
2765
+ # raise TypeError, "x=#{x.inspect} must not be greater #{MAX_FLOATABLE}" unless x <= MAX_FLOATABLE
2766
+ raise TypeError, "x=#{x.inspect} must not positive" unless x >= 0
2679
2767
  check_is_prec(prec, "prec")
2680
2768
  check_is_mode(mode, "mode")
2681
2769
 
2770
+ # handle the special cases where base or exponent are 0 or 1 explicitely
2682
2771
  if y.zero? then
2683
2772
  return LongDecimal.one!(prec)
2684
2773
  elsif x.zero? then
2685
2774
  return LongDecimal.zero!(prec)
2775
+ elsif y.one? then
2776
+ return x.to_ld(prec, mode)
2777
+ elsif x.one? then
2778
+ return LongDecimal.one!(prec)
2686
2779
  end
2687
2780
 
2688
2781
  iprec, iprec_x, iprec_y = calc_iprec_for_power(x, y, prec)