long-decimal 0.01.02 → 0.01.03
Sign up to get free protection for your applications and to get access to all the features.
- data/README +58 -33
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/long-decimal-extra.rb +378 -0
- data/lib/long-decimal.rb +277 -342
- data/test/testlongdecimal-extra.rb +645 -0
- data/test/testlongdecimal.rb +4 -605
- data/test/testlongdeclib.rb +4 -4
- data/test/testrandlib.rb +1 -1
- data/test/testrandom-extra.rb +76 -0
- data/test/testrandom.rb +4 -7
- data/test/testrandpower.rb +7 -4
- data/version.rb +1 -1
- metadata +5 -268
- data/doc/classes/Integer.html +0 -239
- data/doc/classes/Integer.src/M000036.html +0 -18
- data/doc/classes/Integer.src/M000039.html +0 -145
- data/doc/classes/LongDecimal.html +0 -1602
- data/doc/classes/LongDecimal.src/M000034.html +0 -18
- data/doc/classes/LongDecimal.src/M000035.html +0 -18
- data/doc/classes/LongDecimal.src/M000036.html +0 -18
- data/doc/classes/LongDecimal.src/M000037.html +0 -18
- data/doc/classes/LongDecimal.src/M000038.html +0 -18
- data/doc/classes/LongDecimal.src/M000039.html +0 -18
- data/doc/classes/LongDecimal.src/M000040.html +0 -18
- data/doc/classes/LongDecimal.src/M000041.html +0 -18
- data/doc/classes/LongDecimal.src/M000042.html +0 -18
- data/doc/classes/LongDecimal.src/M000043.html +0 -18
- data/doc/classes/LongDecimal.src/M000044.html +0 -18
- data/doc/classes/LongDecimal.src/M000045.html +0 -18
- data/doc/classes/LongDecimal.src/M000046.html +0 -20
- data/doc/classes/LongDecimal.src/M000047.html +0 -120
- data/doc/classes/LongDecimal.src/M000048.html +0 -35
- data/doc/classes/LongDecimal.src/M000049.html +0 -25
- data/doc/classes/LongDecimal.src/M000050.html +0 -41
- data/doc/classes/LongDecimal.src/M000051.html +0 -48
- data/doc/classes/LongDecimal.src/M000052.html +0 -33
- data/doc/classes/LongDecimal.src/M000053.html +0 -18
- data/doc/classes/LongDecimal.src/M000054.html +0 -29
- data/doc/classes/LongDecimal.src/M000055.html +0 -61
- data/doc/classes/LongDecimal.src/M000056.html +0 -18
- data/doc/classes/LongDecimal.src/M000057.html +0 -22
- data/doc/classes/LongDecimal.src/M000058.html +0 -20
- data/doc/classes/LongDecimal.src/M000059.html +0 -18
- data/doc/classes/LongDecimal.src/M000060.html +0 -29
- data/doc/classes/LongDecimal.src/M000061.html +0 -21
- data/doc/classes/LongDecimal.src/M000062.html +0 -18
- data/doc/classes/LongDecimal.src/M000063.html +0 -29
- data/doc/classes/LongDecimal.src/M000064.html +0 -27
- data/doc/classes/LongDecimal.src/M000065.html +0 -18
- data/doc/classes/LongDecimal.src/M000066.html +0 -18
- data/doc/classes/LongDecimal.src/M000067.html +0 -18
- data/doc/classes/LongDecimal.src/M000068.html +0 -19
- data/doc/classes/LongDecimal.src/M000069.html +0 -19
- data/doc/classes/LongDecimal.src/M000070.html +0 -18
- data/doc/classes/LongDecimal.src/M000071.html +0 -18
- data/doc/classes/LongDecimal.src/M000072.html +0 -22
- data/doc/classes/LongDecimal.src/M000073.html +0 -23
- data/doc/classes/LongDecimal.src/M000074.html +0 -23
- data/doc/classes/LongDecimal.src/M000075.html +0 -23
- data/doc/classes/LongDecimal.src/M000076.html +0 -18
- data/doc/classes/LongDecimal.src/M000077.html +0 -33
- data/doc/classes/LongDecimal.src/M000078.html +0 -23
- data/doc/classes/LongDecimal.src/M000079.html +0 -23
- data/doc/classes/LongDecimal.src/M000080.html +0 -35
- data/doc/classes/LongDecimal.src/M000081.html +0 -22
- data/doc/classes/LongDecimal.src/M000082.html +0 -19
- data/doc/classes/LongDecimal.src/M000083.html +0 -23
- data/doc/classes/LongDecimal.src/M000084.html +0 -23
- data/doc/classes/LongDecimal.src/M000085.html +0 -23
- data/doc/classes/LongDecimal.src/M000086.html +0 -18
- data/doc/classes/LongDecimal.src/M000087.html +0 -21
- data/doc/classes/LongDecimal.src/M000088.html +0 -21
- data/doc/classes/LongDecimal.src/M000089.html +0 -18
- data/doc/classes/LongDecimal.src/M000090.html +0 -18
- data/doc/classes/LongDecimal.src/M000091.html +0 -23
- data/doc/classes/LongDecimal.src/M000092.html +0 -23
- data/doc/classes/LongDecimal.src/M000093.html +0 -19
- data/doc/classes/LongDecimal.src/M000094.html +0 -23
- data/doc/classes/LongDecimal.src/M000095.html +0 -18
- data/doc/classes/LongDecimal.src/M000096.html +0 -18
- data/doc/classes/LongDecimal.src/M000097.html +0 -18
- data/doc/classes/LongDecimal.src/M000098.html +0 -18
- data/doc/classes/LongDecimal.src/M000099.html +0 -73
- data/doc/classes/LongDecimal.src/M000100.html +0 -18
- data/doc/classes/LongDecimal.src/M000101.html +0 -18
- data/doc/classes/LongDecimal.src/M000102.html +0 -18
- data/doc/classes/LongDecimal.src/M000103.html +0 -18
- data/doc/classes/LongDecimal.src/M000104.html +0 -19
- data/doc/classes/LongDecimal.src/M000105.html +0 -19
- data/doc/classes/LongDecimal.src/M000106.html +0 -18
- data/doc/classes/LongDecimal.src/M000107.html +0 -18
- data/doc/classes/LongDecimal.src/M000108.html +0 -18
- data/doc/classes/LongDecimal.src/M000109.html +0 -18
- data/doc/classes/LongDecimalBase.html +0 -359
- data/doc/classes/LongDecimalBase.src/M000101.html +0 -18
- data/doc/classes/LongDecimalBase.src/M000102.html +0 -18
- data/doc/classes/LongDecimalBase.src/M000103.html +0 -18
- data/doc/classes/LongDecimalBase.src/M000104.html +0 -18
- data/doc/classes/LongDecimalBase.src/M000105.html +0 -18
- data/doc/classes/LongDecimalBase.src/M000106.html +0 -18
- data/doc/classes/LongDecimalBase.src/M000107.html +0 -18
- data/doc/classes/LongDecimalBase.src/M000108.html +0 -18
- data/doc/classes/LongDecimalBase.src/M000109.html +0 -18
- data/doc/classes/LongDecimalBase.src/M000110.html +0 -18
- data/doc/classes/LongDecimalBase.src/M000111.html +0 -18
- data/doc/classes/LongDecimalBase.src/M000112.html +0 -18
- data/doc/classes/LongDecimalBase.src/M000113.html +0 -18
- data/doc/classes/LongDecimalBase.src/M000114.html +0 -18
- data/doc/classes/LongDecimalBase.src/M000115.html +0 -18
- data/doc/classes/LongDecimalBase.src/M000116.html +0 -18
- data/doc/classes/LongDecimalBase.src/M000117.html +0 -18
- data/doc/classes/LongDecimalBase.src/M000118.html +0 -23
- data/doc/classes/LongDecimalBase.src/M000121.html +0 -23
- data/doc/classes/LongDecimalBase.src/M000122.html +0 -19
- data/doc/classes/LongDecimalBase.src/M000123.html +0 -18
- data/doc/classes/LongDecimalQuot.html +0 -836
- data/doc/classes/LongDecimalQuot.src/M000003.html +0 -18
- data/doc/classes/LongDecimalQuot.src/M000004.html +0 -46
- data/doc/classes/LongDecimalQuot.src/M000005.html +0 -18
- data/doc/classes/LongDecimalQuot.src/M000006.html +0 -18
- data/doc/classes/LongDecimalQuot.src/M000007.html +0 -20
- data/doc/classes/LongDecimalQuot.src/M000008.html +0 -19
- data/doc/classes/LongDecimalQuot.src/M000009.html +0 -18
- data/doc/classes/LongDecimalQuot.src/M000010.html +0 -18
- data/doc/classes/LongDecimalQuot.src/M000011.html +0 -18
- data/doc/classes/LongDecimalQuot.src/M000012.html +0 -18
- data/doc/classes/LongDecimalQuot.src/M000013.html +0 -32
- data/doc/classes/LongDecimalQuot.src/M000014.html +0 -19
- data/doc/classes/LongDecimalQuot.src/M000015.html +0 -19
- data/doc/classes/LongDecimalQuot.src/M000016.html +0 -22
- data/doc/classes/LongDecimalQuot.src/M000017.html +0 -23
- data/doc/classes/LongDecimalQuot.src/M000018.html +0 -23
- data/doc/classes/LongDecimalQuot.src/M000019.html +0 -23
- data/doc/classes/LongDecimalQuot.src/M000020.html +0 -23
- data/doc/classes/LongDecimalQuot.src/M000021.html +0 -35
- data/doc/classes/LongDecimalQuot.src/M000022.html +0 -22
- data/doc/classes/LongDecimalQuot.src/M000023.html +0 -19
- data/doc/classes/LongDecimalQuot.src/M000024.html +0 -18
- data/doc/classes/LongDecimalQuot.src/M000025.html +0 -127
- data/doc/classes/LongDecimalQuot.src/M000026.html +0 -52
- data/doc/classes/LongDecimalQuot.src/M000027.html +0 -18
- data/doc/classes/LongDecimalQuot.src/M000028.html +0 -18
- data/doc/classes/LongDecimalQuot.src/M000029.html +0 -18
- data/doc/classes/LongDecimalQuot.src/M000030.html +0 -18
- data/doc/classes/LongDecimalQuot.src/M000031.html +0 -18
- data/doc/classes/LongDecimalQuot.src/M000032.html +0 -18
- data/doc/classes/LongDecimalQuot.src/M000033.html +0 -18
- data/doc/classes/LongDecimalQuot.src/M000034.html +0 -18
- data/doc/classes/LongDecimalQuot.src/M000035.html +0 -18
- data/doc/classes/LongDecimalRoundingMode.html +0 -242
- data/doc/classes/LongDecimalRoundingMode/RoundingModeClass.html +0 -214
- data/doc/classes/LongDecimalRoundingMode/RoundingModeClass.src/M000135.html +0 -22
- data/doc/classes/LongDecimalRoundingMode/RoundingModeClass.src/M000137.html +0 -22
- data/doc/classes/LongDecimalRoundingMode/RoundingModeClass.src/M000138.html +0 -22
- data/doc/classes/LongDecimalRoundingMode/RoundingModeClass.src/M000141.html +0 -22
- data/doc/classes/LongDecimalRoundingMode/RoundingModeClass.src/M000142.html +0 -18
- data/doc/classes/LongDecimalRoundingMode/RoundingModeClass.src/M000146.html +0 -22
- data/doc/classes/LongDecimalRoundingMode/RoundingModeClass.src/M000147.html +0 -18
- data/doc/classes/LongDecimalRoundingMode/RoundingModeClass.src/M000148.html +0 -22
- data/doc/classes/LongDecimalRoundingMode/RoundingModeClass.src/M000149.html +0 -18
- data/doc/classes/LongDecimalRoundingMode/RoundingModeClass.src/M000150.html +0 -22
- data/doc/classes/LongDecimalRoundingMode/RoundingModeClass.src/M000151.html +0 -18
- data/doc/classes/LongDecimalRoundingMode/RoundingModeClass.src/M000152.html +0 -18
- data/doc/classes/LongDecimalRoundingMode/RoundingModeClass.src/M000156.html +0 -22
- data/doc/classes/LongDecimalRoundingMode/RoundingModeClass.src/M000157.html +0 -18
- data/doc/classes/LongDecimalRoundingMode/RoundingModeClass.src/M000158.html +0 -18
- data/doc/classes/LongDecimalRoundingMode/RoundingModeClass.src/M000159.html +0 -18
- data/doc/classes/LongDecimalRoundingMode/RoundingModeClass.src/M000161.html +0 -25
- data/doc/classes/LongDecimalRoundingMode/RoundingModeClass.src/M000162.html +0 -18
- data/doc/classes/LongDecimalRoundingMode/RoundingModeClass.src/M000163.html +0 -18
- data/doc/classes/LongDecimalRoundingMode/RoundingModeClass.src/M000164.html +0 -18
- data/doc/classes/LongDecimalRoundingMode/ZeroRoundingModeClass.html +0 -178
- data/doc/classes/LongDecimalRoundingMode/ZeroRoundingModeClass.src/M000165.html +0 -25
- data/doc/classes/LongDecimalRoundingMode/ZeroRoundingModeClass.src/M000166.html +0 -18
- data/doc/classes/LongMath.html +0 -911
- data/doc/classes/LongMath.src/M000112.html +0 -19
- data/doc/classes/LongMath.src/M000113.html +0 -19
- data/doc/classes/LongMath.src/M000114.html +0 -18
- data/doc/classes/LongMath.src/M000115.html +0 -19
- data/doc/classes/LongMath.src/M000116.html +0 -19
- data/doc/classes/LongMath.src/M000117.html +0 -18
- data/doc/classes/LongMath.src/M000118.html +0 -19
- data/doc/classes/LongMath.src/M000119.html +0 -19
- data/doc/classes/LongMath.src/M000120.html +0 -18
- data/doc/classes/LongMath.src/M000121.html +0 -18
- data/doc/classes/LongMath.src/M000122.html +0 -19
- data/doc/classes/LongMath.src/M000123.html +0 -18
- data/doc/classes/LongMath.src/M000124.html +0 -19
- data/doc/classes/LongMath.src/M000125.html +0 -18
- data/doc/classes/LongMath.src/M000126.html +0 -18
- data/doc/classes/LongMath.src/M000127.html +0 -19
- data/doc/classes/LongMath.src/M000128.html +0 -18
- data/doc/classes/LongMath.src/M000129.html +0 -32
- data/doc/classes/LongMath.src/M000130.html +0 -32
- data/doc/classes/LongMath.src/M000131.html +0 -19
- data/doc/classes/LongMath.src/M000132.html +0 -43
- data/doc/classes/LongMath.src/M000133.html +0 -19
- data/doc/classes/LongMath.src/M000134.html +0 -71
- data/doc/classes/LongMath.src/M000135.html +0 -35
- data/doc/classes/LongMath.src/M000136.html +0 -50
- data/doc/classes/LongMath.src/M000137.html +0 -20
- data/doc/classes/LongMath.src/M000138.html +0 -47
- data/doc/classes/LongMath.src/M000139.html +0 -65
- data/doc/classes/LongMath.src/M000140.html +0 -21
- data/doc/classes/LongMath.src/M000141.html +0 -18
- data/doc/classes/LongMath.src/M000142.html +0 -18
- data/doc/classes/LongMath.src/M000143.html +0 -87
- data/doc/classes/LongMath.src/M000144.html +0 -58
- data/doc/classes/LongMath.src/M000145.html +0 -18
- data/doc/classes/LongMath.src/M000146.html +0 -18
- data/doc/classes/LongMath.src/M000147.html +0 -20
- data/doc/classes/LongMath.src/M000148.html +0 -34
- data/doc/classes/LongMath.src/M000149.html +0 -33
- data/doc/classes/LongMath.src/M000150.html +0 -58
- data/doc/classes/LongMath.src/M000151.html +0 -406
- data/doc/classes/LongMath.src/M000152.html +0 -63
- data/doc/classes/LongMath.src/M000153.html +0 -117
- data/doc/classes/LongMath.src/M000154.html +0 -150
- data/doc/classes/LongMath.src/M000155.html +0 -63
- data/doc/classes/LongMath.src/M000156.html +0 -18
- data/doc/classes/LongMath.src/M000157.html +0 -19
- data/doc/classes/LongMath.src/M000158.html +0 -18
- data/doc/classes/LongMath.src/M000159.html +0 -19
- data/doc/classes/LongMath/CacheKey.html +0 -164
- data/doc/classes/LongMath/CacheKey.src/M000140.html +0 -36
- data/doc/classes/LongMath/CacheKey.src/M000145.html +0 -36
- data/doc/classes/LongMath/CacheKey.src/M000147.html +0 -36
- data/doc/classes/LongMath/CacheKey.src/M000149.html +0 -36
- data/doc/classes/LongMath/CacheKey.src/M000155.html +0 -36
- data/doc/classes/LongMath/CacheKey.src/M000160.html +0 -36
- data/doc/classes/Numeric.html +0 -177
- data/doc/classes/Numeric.src/M000100.html +0 -23
- data/doc/classes/Numeric.src/M000102.html +0 -23
- data/doc/classes/Numeric.src/M000103.html +0 -18
- data/doc/classes/Numeric.src/M000104.html +0 -23
- data/doc/classes/Numeric.src/M000105.html +0 -23
- data/doc/classes/Numeric.src/M000106.html +0 -18
- data/doc/classes/Numeric.src/M000110.html +0 -23
- data/doc/classes/Numeric.src/M000111.html +0 -18
- data/doc/classes/Rational.html +0 -161
- data/doc/classes/Rational.src/M000101.html +0 -23
- data/doc/classes/Rational.src/M000103.html +0 -23
- data/doc/classes/Rational.src/M000104.html +0 -23
- data/doc/classes/Rational.src/M000106.html +0 -23
- data/doc/classes/Rational.src/M000107.html +0 -23
- data/doc/classes/Rational.src/M000112.html +0 -23
- data/doc/created.rid +0 -1
- data/doc/dot/f_0.dot +0 -166
- data/doc/dot/f_0.png +0 -0
- data/doc/dot/m_0_0.dot +0 -59
- data/doc/dot/m_0_0.png +0 -0
- data/doc/dot/m_0_1.dot +0 -62
- data/doc/dot/m_0_1.png +0 -0
- data/doc/files/lib/long-decimal_rb.html +0 -191
- data/doc/files/lib/long-decimal_rb.src/M000001.html +0 -22
- data/doc/files/lib/long-decimal_rb.src/M000002.html +0 -18
- data/doc/fr_class_index.html +0 -37
- data/doc/fr_file_index.html +0 -27
- data/doc/fr_method_index.html +0 -192
- data/doc/index.html +0 -24
- data/doc/rdoc-style.css +0 -208
data/test/testlongdecimal.rb
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
#
|
3
3
|
# testlongdecimal.rb -- runit test for long-decimal.rb
|
4
4
|
#
|
5
|
-
# CVS-ID: $Header: /var/cvs/long-decimal/long-decimal/test/testlongdecimal.rb,v 1.
|
6
|
-
# CVS-Label: $Name:
|
5
|
+
# CVS-ID: $Header: /var/cvs/long-decimal/long-decimal/test/testlongdecimal.rb,v 1.63 2007/08/19 19:25:59 bk1 Exp $
|
6
|
+
# CVS-Label: $Name: ALPHA_01_03 $
|
7
7
|
# Author: $Author: bk1 $ (Karl Brodowsky)
|
8
8
|
#
|
9
9
|
|
@@ -11,7 +11,7 @@ require "runit/testcase"
|
|
11
11
|
require "runit/cui/testrunner"
|
12
12
|
require "runit/testsuite"
|
13
13
|
|
14
|
-
|
14
|
+
load "lib/long-decimal.rb"
|
15
15
|
load "test/testlongdeclib.rb"
|
16
16
|
|
17
17
|
#
|
@@ -20,7 +20,7 @@ load "test/testlongdeclib.rb"
|
|
20
20
|
class TestLongDecimal_class < RUNIT::TestCase
|
21
21
|
include TestLongDecHelper
|
22
22
|
|
23
|
-
@RCS_ID='-$Id: testlongdecimal.rb,v 1.
|
23
|
+
@RCS_ID='-$Id: testlongdecimal.rb,v 1.63 2007/08/19 19:25:59 bk1 Exp $-'
|
24
24
|
|
25
25
|
#
|
26
26
|
# test split_to_words and merge_from_words
|
@@ -151,327 +151,6 @@ class TestLongDecimal_class < RUNIT::TestCase
|
|
151
151
|
|
152
152
|
end
|
153
153
|
|
154
|
-
#
|
155
|
-
# test exp2 of LongMath
|
156
|
-
#
|
157
|
-
def test_exp2
|
158
|
-
10.times do |i|
|
159
|
-
n = (i*i+i)/2
|
160
|
-
x = LongDecimal(n, 3*i)+LongMath.pi(20)
|
161
|
-
check_exp2_floated(x, n)
|
162
|
-
|
163
|
-
y = LongMath.exp2(x, n)
|
164
|
-
yy = LongMath.exp2(x, n + 5)
|
165
|
-
assert_equal(yy.round_to_scale(y.scale, LongDecimal::ROUND_HALF_DOWN), y, "x=#{x} y=#{y} yy=#{yy}")
|
166
|
-
z = LongMath.power(2, x, n)
|
167
|
-
assert_equal(z, y, "exp2 x=#{x} y=#{y} z=#{z} i=#{i} n=#{n}")
|
168
|
-
end
|
169
|
-
|
170
|
-
# random tests that have failed previously
|
171
|
-
check_exp2_floated(LongDecimal("-0.00147492625237084606064197462823289474038138852346725504592707365251736299180323394082648207114993022483949313246714392730651107673327728615912046468517225938833913598854936005"), 20)
|
172
|
-
|
173
|
-
end
|
174
|
-
|
175
|
-
#
|
176
|
-
# test the calculation of the exponential function where result is
|
177
|
-
# near zero
|
178
|
-
#
|
179
|
-
def test_exp2_near_zero
|
180
|
-
|
181
|
-
x = LongDecimal(1, 100)
|
182
|
-
y = LongMath.log2(x, 100)
|
183
|
-
z = check_exp2_floated(y, 100)
|
184
|
-
assert_equal(x, z, "must be equal")
|
185
|
-
z = check_exp2_floated(y, 99)
|
186
|
-
assert(z.zero?, "must be zero")
|
187
|
-
z = check_exp2_floated(y * 100, 99)
|
188
|
-
assert(z.zero?, "must be zero")
|
189
|
-
|
190
|
-
end
|
191
|
-
|
192
|
-
#
|
193
|
-
# test exp10 of LongMath
|
194
|
-
#
|
195
|
-
def test_exp10
|
196
|
-
10.times do |i|
|
197
|
-
n = (i*i+i)/2
|
198
|
-
x = LongDecimal(n, 3*i)+LongMath.pi(20)
|
199
|
-
check_exp10_floated(x, n)
|
200
|
-
|
201
|
-
y = LongMath.exp10(x, n)
|
202
|
-
yy = LongMath.exp10(x, n + 5)
|
203
|
-
assert_equal(yy.round_to_scale(y.scale, LongDecimal::ROUND_HALF_DOWN), y, "x=#{x} y=#{y} yy=#{yy}")
|
204
|
-
z = LongMath.power(10, x, n)
|
205
|
-
assert_equal(z, y, "exp10 x=#{x} y=#{y} z=#{z} i=#{i} n=#{n}")
|
206
|
-
end
|
207
|
-
end
|
208
|
-
|
209
|
-
#
|
210
|
-
# test the calculation of the exponential function where result is
|
211
|
-
# near zero
|
212
|
-
#
|
213
|
-
def test_exp10_near_zero
|
214
|
-
|
215
|
-
x = LongDecimal(1, 100)
|
216
|
-
y = LongMath.log10(x, 100)
|
217
|
-
z = check_exp10_floated(y, 100)
|
218
|
-
assert_equal(x, z, "must be equal")
|
219
|
-
z = check_exp10_floated(y, 99)
|
220
|
-
assert(z.zero?, "must be zero")
|
221
|
-
z = check_exp10_floated(y * 100, 99)
|
222
|
-
assert(z.zero?, "must be zero")
|
223
|
-
|
224
|
-
end
|
225
|
-
|
226
|
-
#
|
227
|
-
# test LongMath.power for bases that can be expressed as integer
|
228
|
-
#
|
229
|
-
def test_lm_power_xint
|
230
|
-
|
231
|
-
xx = LongMath.log(3, 40)
|
232
|
-
pi = LongMath.pi(40)
|
233
|
-
sq = LongMath.sqrt(5, 40)
|
234
|
-
|
235
|
-
check_power_xint(2, 700.01, 10)
|
236
|
-
check_power_xint(2, 100.001, 10)
|
237
|
-
check_power_xint(2, 1.000000001, 10)
|
238
|
-
check_power_xint(2, 0.01, 10)
|
239
|
-
check_power_xint(2, 1e-10, 10)
|
240
|
-
check_power_xint(2, 1e-90, 10)
|
241
|
-
check_power_xint(2, 0, 10)
|
242
|
-
check_power_xint(2, -1.000000001, 10)
|
243
|
-
check_power_xint(2, -100.001, 10)
|
244
|
-
check_power_xint(2, -700.01, 10)
|
245
|
-
check_power_xint(2, xx, 10)
|
246
|
-
check_power_xint(2, pi, 10)
|
247
|
-
check_power_xint(2, sq, 10)
|
248
|
-
|
249
|
-
check_power_xint(10, 308.01, 10)
|
250
|
-
check_power_xint(10, 100.001, 10)
|
251
|
-
check_power_xint(10, 1.000000001, 10)
|
252
|
-
check_power_xint(10, 0.01, 10)
|
253
|
-
check_power_xint(10, 1e-10, 10)
|
254
|
-
check_power_xint(10, 1e-90, 10)
|
255
|
-
check_power_xint(10, 0, 10)
|
256
|
-
check_power_xint(10, -1.000000001, 10)
|
257
|
-
check_power_xint(10, -100.001, 10)
|
258
|
-
check_power_xint(10, -308.01, 10)
|
259
|
-
check_power_xint(10, xx, 10)
|
260
|
-
check_power_xint(10, pi, 10)
|
261
|
-
check_power_xint(10, sq, 10)
|
262
|
-
|
263
|
-
check_power_xint(2, 700.01, 100)
|
264
|
-
check_power_xint(2, 100.001, 100)
|
265
|
-
check_power_xint(2, 1.000000001, 100)
|
266
|
-
check_power_xint(2, 0.01, 100)
|
267
|
-
check_power_xint(2, 1e-10, 100)
|
268
|
-
check_power_xint(2, 1e-90, 100)
|
269
|
-
check_power_xint(2, 0, 100)
|
270
|
-
check_power_xint(2, -1.000000001, 100)
|
271
|
-
check_power_xint(2, -100.001, 100)
|
272
|
-
check_power_xint(2, -700.01, 100)
|
273
|
-
check_power_xint(2, xx, 100)
|
274
|
-
check_power_xint(2, pi, 100)
|
275
|
-
check_power_xint(2, sq, 100)
|
276
|
-
|
277
|
-
check_power_xint(10, 308.01, 100)
|
278
|
-
check_power_xint(10, 100.001, 100)
|
279
|
-
check_power_xint(10, 1.000000001, 100)
|
280
|
-
check_power_xint(10, 0.01, 100)
|
281
|
-
check_power_xint(10, 1e-10, 100)
|
282
|
-
check_power_xint(10, 1e-90, 100)
|
283
|
-
check_power_xint(10, 0, 100)
|
284
|
-
check_power_xint(10, -1.000000001, 100)
|
285
|
-
check_power_xint(10, -100.001, 100)
|
286
|
-
check_power_xint(10, -308.01, 100)
|
287
|
-
check_power_xint(10, xx, 100)
|
288
|
-
check_power_xint(10, pi, 100)
|
289
|
-
check_power_xint(10, sq, 100)
|
290
|
-
|
291
|
-
check_power_xint(2, 700.01, 40)
|
292
|
-
check_power_xint(2, 100.001, 40)
|
293
|
-
check_power_xint(2, 1.000000001, 40)
|
294
|
-
check_power_xint(2, 0.01, 40)
|
295
|
-
check_power_xint(2, 1e-10, 40)
|
296
|
-
check_power_xint(2, 1e-90, 40)
|
297
|
-
check_power_xint(2, 0, 40)
|
298
|
-
check_power_xint(2, -1.000000001, 40)
|
299
|
-
check_power_xint(2, -100.001, 40)
|
300
|
-
check_power_xint(2, -700.01, 40)
|
301
|
-
check_power_xint(2, xx, 40)
|
302
|
-
check_power_xint(2, pi, 40)
|
303
|
-
check_power_xint(2, sq, 40)
|
304
|
-
|
305
|
-
check_power_xint(10, 308.01, 40)
|
306
|
-
check_power_xint(10, 100.001, 40)
|
307
|
-
check_power_xint(10, 1.000000001, 40)
|
308
|
-
check_power_xint(10, 0.01, 40)
|
309
|
-
check_power_xint(10, 1e-10, 40)
|
310
|
-
check_power_xint(10, 1e-90, 40)
|
311
|
-
check_power_xint(10, 0, 40)
|
312
|
-
check_power_xint(10, -1.000000001, 40)
|
313
|
-
check_power_xint(10, -100.001, 40)
|
314
|
-
check_power_xint(10, -308.01, 40)
|
315
|
-
check_power_xint(10, xx, 40)
|
316
|
-
check_power_xint(10, pi, 40)
|
317
|
-
check_power_xint(10, sq, 40)
|
318
|
-
|
319
|
-
end
|
320
|
-
|
321
|
-
#
|
322
|
-
# test LongMath.power for bases that can be expressed as integer
|
323
|
-
#
|
324
|
-
def test_lm_power_yint
|
325
|
-
|
326
|
-
xx = LongMath.log(3, 40)
|
327
|
-
pi = LongMath.pi(40)
|
328
|
-
sq = LongMath.sqrt(5, 40)
|
329
|
-
|
330
|
-
check_power_yint(xx, 400, 10)
|
331
|
-
check_power_yint(xx, 100, 10)
|
332
|
-
check_power_yint(xx, 1, 10)
|
333
|
-
check_power_yint(xx, 0, 10)
|
334
|
-
check_power_yint(xx, -1, 10)
|
335
|
-
check_power_yint(xx, -100, 10)
|
336
|
-
check_power_yint(xx, -400, 10)
|
337
|
-
|
338
|
-
check_power_yint(pi, 400, 10)
|
339
|
-
check_power_yint(pi, 100, 10)
|
340
|
-
check_power_yint(pi, 1, 10)
|
341
|
-
check_power_yint(pi, 0, 10)
|
342
|
-
check_power_yint(pi, -1, 10)
|
343
|
-
check_power_yint(pi, -100, 10)
|
344
|
-
check_power_yint(pi, -400, 10)
|
345
|
-
|
346
|
-
check_power_yint(sq, 400, 10)
|
347
|
-
check_power_yint(sq, 100, 10)
|
348
|
-
check_power_yint(sq, 1, 10)
|
349
|
-
check_power_yint(sq, 0, 10)
|
350
|
-
check_power_yint(sq, -1, 10)
|
351
|
-
check_power_yint(sq, -100, 10)
|
352
|
-
check_power_yint(sq, -400, 10)
|
353
|
-
|
354
|
-
check_power_yint(xx, 400, 100)
|
355
|
-
check_power_yint(xx, 100, 100)
|
356
|
-
check_power_yint(xx, 1, 100)
|
357
|
-
check_power_yint(xx, 0, 100)
|
358
|
-
check_power_yint(xx, -1, 100)
|
359
|
-
check_power_yint(xx, -100, 100)
|
360
|
-
check_power_yint(xx, -400, 100)
|
361
|
-
|
362
|
-
check_power_yint(pi, 400, 100)
|
363
|
-
check_power_yint(pi, 100, 100)
|
364
|
-
check_power_yint(pi, 1, 100)
|
365
|
-
check_power_yint(pi, 0, 100)
|
366
|
-
check_power_yint(pi, -1, 100)
|
367
|
-
check_power_yint(pi, -100, 100)
|
368
|
-
check_power_yint(pi, -400, 100)
|
369
|
-
|
370
|
-
check_power_yint(sq, 400, 100)
|
371
|
-
check_power_yint(sq, 100, 100)
|
372
|
-
check_power_yint(sq, 1, 100)
|
373
|
-
check_power_yint(sq, 0, 100)
|
374
|
-
check_power_yint(sq, -1, 100)
|
375
|
-
check_power_yint(sq, -100, 100)
|
376
|
-
check_power_yint(sq, -400, 100)
|
377
|
-
|
378
|
-
check_power_yint(xx, 400, 40)
|
379
|
-
check_power_yint(xx, 100, 40)
|
380
|
-
check_power_yint(xx, 1, 40)
|
381
|
-
check_power_yint(xx, 0, 40)
|
382
|
-
check_power_yint(xx, -1, 40)
|
383
|
-
check_power_yint(xx, -100, 40)
|
384
|
-
check_power_yint(xx, -400, 40)
|
385
|
-
|
386
|
-
check_power_yint(pi, 400, 40)
|
387
|
-
check_power_yint(pi, 100, 40)
|
388
|
-
check_power_yint(pi, 1, 40)
|
389
|
-
check_power_yint(pi, 0, 40)
|
390
|
-
check_power_yint(pi, -1, 40)
|
391
|
-
check_power_yint(pi, -100, 40)
|
392
|
-
check_power_yint(pi, -400, 40)
|
393
|
-
|
394
|
-
check_power_yint(sq, 400, 40)
|
395
|
-
check_power_yint(sq, 100, 40)
|
396
|
-
check_power_yint(sq, 1, 40)
|
397
|
-
check_power_yint(sq, 0, 40)
|
398
|
-
check_power_yint(sq, -1, 40)
|
399
|
-
check_power_yint(sq, -100, 40)
|
400
|
-
check_power_yint(sq, -400, 40)
|
401
|
-
|
402
|
-
end
|
403
|
-
|
404
|
-
#
|
405
|
-
# test LongMath.power for bases that can be expressed as integer
|
406
|
-
#
|
407
|
-
def test_lm_power_yhalfint
|
408
|
-
|
409
|
-
xx = LongMath.log(3, 40)
|
410
|
-
pi = LongMath.pi(40)
|
411
|
-
sq = LongMath.sqrt(5, 40)
|
412
|
-
|
413
|
-
check_power_yhalfint(xx, 801, 10)
|
414
|
-
check_power_yhalfint(xx, 799, 10)
|
415
|
-
check_power_yhalfint(xx, 201, 10)
|
416
|
-
check_power_yhalfint(xx, 3, 10)
|
417
|
-
check_power_yhalfint(xx, 1, 10)
|
418
|
-
check_power_yhalfint(xx, -1, 10)
|
419
|
-
check_power_yhalfint(xx, -201, 10)
|
420
|
-
check_power_yhalfint(xx, -799, 10)
|
421
|
-
check_power_yhalfint(xx, -801, 10)
|
422
|
-
|
423
|
-
check_power_yhalfint(pi, 801, 10)
|
424
|
-
check_power_yhalfint(pi, 799, 10)
|
425
|
-
check_power_yhalfint(pi, 201, 10)
|
426
|
-
check_power_yhalfint(pi, 3, 10)
|
427
|
-
check_power_yhalfint(pi, 1, 10)
|
428
|
-
check_power_yhalfint(pi, -1, 10)
|
429
|
-
check_power_yhalfint(pi, -201, 10)
|
430
|
-
check_power_yhalfint(pi, -799, 10)
|
431
|
-
check_power_yhalfint(pi, -801, 10)
|
432
|
-
|
433
|
-
check_power_yhalfint(sq, 801, 10)
|
434
|
-
check_power_yhalfint(sq, 799, 10)
|
435
|
-
check_power_yhalfint(sq, 201, 10)
|
436
|
-
check_power_yhalfint(sq, 3, 10)
|
437
|
-
check_power_yhalfint(sq, 1, 10)
|
438
|
-
check_power_yhalfint(sq, -1, 10)
|
439
|
-
check_power_yhalfint(sq, -201, 10)
|
440
|
-
check_power_yhalfint(sq, -799, 10)
|
441
|
-
check_power_yhalfint(sq, -801, 10)
|
442
|
-
|
443
|
-
check_power_yhalfint(xx, 801, 40)
|
444
|
-
check_power_yhalfint(xx, 799, 40)
|
445
|
-
check_power_yhalfint(xx, 201, 40)
|
446
|
-
check_power_yhalfint(xx, 3, 40)
|
447
|
-
check_power_yhalfint(xx, 1, 40)
|
448
|
-
check_power_yhalfint(xx, -1, 40)
|
449
|
-
check_power_yhalfint(xx, -201, 40)
|
450
|
-
check_power_yhalfint(xx, -799, 40)
|
451
|
-
check_power_yhalfint(xx, -801, 40)
|
452
|
-
|
453
|
-
check_power_yhalfint(pi, 801, 40)
|
454
|
-
check_power_yhalfint(pi, 799, 40)
|
455
|
-
check_power_yhalfint(pi, 201, 40)
|
456
|
-
check_power_yhalfint(pi, 3, 40)
|
457
|
-
check_power_yhalfint(pi, 1, 40)
|
458
|
-
check_power_yhalfint(pi, -1, 40)
|
459
|
-
check_power_yhalfint(pi, -201, 40)
|
460
|
-
check_power_yhalfint(pi, -799, 40)
|
461
|
-
check_power_yhalfint(pi, -801, 40)
|
462
|
-
|
463
|
-
check_power_yhalfint(sq, 801, 40)
|
464
|
-
check_power_yhalfint(sq, 799, 40)
|
465
|
-
check_power_yhalfint(sq, 201, 40)
|
466
|
-
check_power_yhalfint(sq, 3, 40)
|
467
|
-
check_power_yhalfint(sq, 1, 40)
|
468
|
-
check_power_yhalfint(sq, -1, 40)
|
469
|
-
check_power_yhalfint(sq, -201, 40)
|
470
|
-
check_power_yhalfint(sq, -799, 40)
|
471
|
-
check_power_yhalfint(sq, -801, 40)
|
472
|
-
|
473
|
-
end
|
474
|
-
|
475
154
|
#
|
476
155
|
# test LongMath.exp with non-LongDecimal arguments
|
477
156
|
#
|
@@ -518,33 +197,6 @@ class TestLongDecimal_class < RUNIT::TestCase
|
|
518
197
|
assert((zr-xr).abs <= zr.unit, "zr-xr zr=#{zr}")
|
519
198
|
end
|
520
199
|
|
521
|
-
#
|
522
|
-
# test LongMath.power with non-LongDecimal arguments
|
523
|
-
#
|
524
|
-
def test_non_ld_power
|
525
|
-
xi = 77
|
526
|
-
yi = 88
|
527
|
-
zi = LongMath.power(xi, yi, 35)
|
528
|
-
wi = (LongMath.log(zi, 40) / LongMath.log(xi, 40)).round_to_scale(30, LongMath::ROUND_HALF_EVEN)
|
529
|
-
assert(wi.is_int?, "wi=#{wi} not int (zi=#{zi})")
|
530
|
-
assert_equal(yi, wi.to_i, "zi=#{zi} wi=#{wi}")
|
531
|
-
zj = LongMath.power_internal(xi, yi, 35)
|
532
|
-
assert_equal(zi, zj, "internal power should yield the same result zi=#{zi} zj=#{zj}")
|
533
|
-
|
534
|
-
xf = 77.0
|
535
|
-
yf = 88.0
|
536
|
-
zf = LongMath.power(xf, yf, 35)
|
537
|
-
wf = (LongMath.log(zf, 40) / LongMath.log(xf, 40)).round_to_scale(30, LongMath::ROUND_HALF_EVEN)
|
538
|
-
assert(wf.is_int?, "wf=#{wf} not int (zf=#{zf} wi=#{wi} zi=#{zi}")
|
539
|
-
assert_equal(yf, wf.to_i, "yf=#{yf} wf=#{yf}")
|
540
|
-
|
541
|
-
xr = Rational(224, 225)
|
542
|
-
yr = Rational(168, 169)
|
543
|
-
zr = LongMath.power(xr, yr, 35)
|
544
|
-
wr = (LongMath.log(zr, 40) / LongMath.log(xr, 40)).round_to_scale(30, LongMath::ROUND_HALF_EVEN)
|
545
|
-
assert((yr-wr).abs <= wr.unit, "wr-yr")
|
546
|
-
end
|
547
|
-
|
548
200
|
#
|
549
201
|
# test the calculation of the logarithm function
|
550
202
|
#
|
@@ -595,251 +247,6 @@ class TestLongDecimal_class < RUNIT::TestCase
|
|
595
247
|
|
596
248
|
end
|
597
249
|
|
598
|
-
#
|
599
|
-
# test the calculation of the power-function of LongMath
|
600
|
-
#
|
601
|
-
def test_lm_power
|
602
|
-
check_power_floated(1.001, 1.001, 10)
|
603
|
-
check_power_floated(1.001, 2.001, 10)
|
604
|
-
check_power_floated(2.001, 1.001, 10)
|
605
|
-
check_power_floated(2.001, 2.001, 10)
|
606
|
-
check_power_floated(100.001, 10.001, 10)
|
607
|
-
check_power_floated(10.001, 100.001, 10)
|
608
|
-
check_power_floated(10.001, 100.001, 100)
|
609
|
-
check_power_floated(1e-20, 1.01, 19)
|
610
|
-
check_power_floated(1.01, 1e-20, 19)
|
611
|
-
check_power_floated(1e-20, 1.01, 20)
|
612
|
-
check_power_floated(1.01, 1e-20, 20)
|
613
|
-
check_power_floated(1e-20, 1.01, 21)
|
614
|
-
check_power_floated(1.01, 1e-20, 21)
|
615
|
-
puts "done (1.01, 1e-20, 21)"
|
616
|
-
|
617
|
-
check_power_floated(1.001, -1.001, 10)
|
618
|
-
check_power_floated(1.001, -2.001, 10)
|
619
|
-
check_power_floated(2.001, -1.001, 10)
|
620
|
-
check_power_floated(2.001, -2.001, 10)
|
621
|
-
check_power_floated(100.001, -10.001, 10)
|
622
|
-
check_power_floated(10.001, -100.001, 10)
|
623
|
-
check_power_floated(1e-20, -1.01, 19)
|
624
|
-
check_power_floated(1.01, -1e-20, 19)
|
625
|
-
check_power_floated(1e-20, -1.01, 20)
|
626
|
-
check_power_floated(1.01, -1e-20, 20)
|
627
|
-
check_power_floated(1e-20, -1.01, 21)
|
628
|
-
check_power_floated(1.01, -1e-20, 21)
|
629
|
-
puts "done (1.01, -1e-20, 21)"
|
630
|
-
|
631
|
-
# random tests that have failed
|
632
|
-
check_power_floated(LongDecimal("0.000000000077517987624900000000000000000000000000000000000000000000000000000000000000000000000000000014809051260000000000000000000000000000000000000000000000000000000000000000000000000000000000707281"),
|
633
|
-
LongDecimal("26.627053911388694974442854299008649887946027550330988420533923061901183724914978160564862753777080769340"),
|
634
|
-
29)
|
635
|
-
puts "a"
|
636
|
-
check_power_floated(LongDecimal("1.000000000000000151000000000000000000000000000000000000000000000000000000000000057800000000205"),
|
637
|
-
LongDecimal("-680.0000000000000000000013100000000000000000000000000000000000000165000000000000000000234"),
|
638
|
-
26)
|
639
|
-
puts "b"
|
640
|
-
check_power_floated(LongDecimal("1.0000000000000000000000000000000000000000000068000000000853000000000926"),
|
641
|
-
LongDecimal("-536.000000000086100000000000000000000000000019200000000000000000000000000000000000000000000000166"),
|
642
|
-
49)
|
643
|
-
puts "c"
|
644
|
-
check_power_floated(LongDecimal("1.0000000000000000049000000000002090000000000447"),
|
645
|
-
LongDecimal("-328.00000000000000000000000000000000567000000000000000026600000000000000000000000679"),
|
646
|
-
24)
|
647
|
-
puts "d"
|
648
|
-
check_power_floated(LongDecimal("1.0000000000000000000003580000000000000000000000376238"),
|
649
|
-
LongDecimal("-359.0000000003910721000000000000000000000000000000000000000000000000000000000000000000000000479"),
|
650
|
-
39)
|
651
|
-
puts "e"
|
652
|
-
check_power_floated(LongDecimal("1.000000000000000000000032000000001500000000000000000000439"),
|
653
|
-
LongDecimal("-252.00000000000000025500000000000176907"),
|
654
|
-
39)
|
655
|
-
puts "f"
|
656
|
-
check_power_floated(LongDecimal("1.0000000000000008590000521000000000000621"),
|
657
|
-
LongDecimal("-135.0000000000000000000000000000000000000000000000000000000074400000000000000000000000000321"),
|
658
|
-
50)
|
659
|
-
puts "g"
|
660
|
-
check_power_floated(LongDecimal("1.000000000000000151000000000000000000000000000000000000000000000000000000000000057800000000205"),
|
661
|
-
LongDecimal("-680.0000000000000000000013100000000000000000000000000000000000000165000000000000000000234"),
|
662
|
-
26)
|
663
|
-
puts "h"
|
664
|
-
check_power_floated(LongDecimal("1.02350000000000000000000356000000000000000000000000000000000000000000000000000000000104"),
|
665
|
-
LongDecimal("-971.0000000000000000055400000000000000000000000000000000000000000000000000040900000000000000000000000603"),
|
666
|
-
45)
|
667
|
-
puts "i"
|
668
|
-
check_power_floated(LongDecimal("1.0023800000000000000000000000000000000000000000000000000000000000265000000000000000000000000000000453"),
|
669
|
-
LongDecimal("-277.000000000000000000000000000000000000000000000000000000000000113000000000000000000041400000294"),
|
670
|
-
22)
|
671
|
-
puts "j"
|
672
|
-
check_power_floated(LongDecimal("0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003422250001093950095910422515315300670761"),
|
673
|
-
LongDecimal("-0.99999999999999999999999999999999999999999999999999997909999999999999999999999999667999957000000000000000065521500000000000000000000020816402696099999999999997719321110428280027729999999129874367303020000000000071412895105695789681563000036363932570289984431712381817869482773696988055442648559706239710901091550702341077381290973316336980640165855210736680"),
|
674
|
-
46)
|
675
|
-
puts "k"
|
676
|
-
check_power_floated(LongDecimal("0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000049273899694369"),
|
677
|
-
LongDecimal("-0.99999999999999999999999999999999999999988899963450000000000000000000000000000001847988671170038537499999999999999999999658146648184996349480690906250000000000066400422857493760370353798820585648437488207957808220483456569835670219978619056054192244103752969215743872596800486621906638928959243058783356441503226136251748249991020724187893339868"),
|
678
|
-
40)
|
679
|
-
puts "l"
|
680
|
-
check_power_floated(LongDecimal("0.0000000000000000000000000000003868840000000000000000000328416000000000000000000006969600000000000000000000000000000059338800000000000000000002518560000000000000000000000000000000000000000000000000000000227529"),
|
681
|
-
LongDecimal("-0.999999999999999999999999999999999999999999999999999998264999999999999999999999999999616741000000000000000004515337500000000000000000000001994863094999999999999986943149282831191620999999999993077825060350000000000033980453035745280148525000000024019946927993617107497210600671335038418031107762499920991889855598841096454678838495791189026426859181655270271342"),
|
682
|
-
31)
|
683
|
-
puts "m"
|
684
|
-
check_power_floated(LongDecimal("0.0000000000000000000000000000000000000000000000435600000000000000000000000000000000000000000000000006204000000075240000000000000000000000000000000000000022090000000535800000003249"),
|
685
|
-
LongDecimal("-4.50377349099168904759987513420506734335755704389619751192197520413005925604849718759451665302464588879636922713303481423460050066204079523260315868192642742903330525895063299416"),
|
686
|
-
20)
|
687
|
-
puts "n"
|
688
|
-
check_power_floated(LongDecimal("0.0000000000000000000000000000700720943029391693947940220429504569709269190190365416713568"),
|
689
|
-
LongDecimal("-6.633249580710799698229865473341373367854177091179010213018664944871230"),
|
690
|
-
7)
|
691
|
-
puts "o"
|
692
|
-
check_power_floated(LongDecimal("0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000816700000697"),
|
693
|
-
LongDecimal("-0.58685446009389671361502347417840375586854460093896713614906034406753510106019528753113359342280707917300359276157963863070992095386428055722936293804476401957909668625460628698383384886591034139"),
|
694
|
-
36)
|
695
|
-
puts "p"
|
696
|
-
check_power_floated(LongDecimal("0.000000000000000000000000000000000000046500000000000015087"),
|
697
|
-
LongDecimal("-1.0000000037300000000000000000000000000000000000000000003924"),
|
698
|
-
3)
|
699
|
-
puts "q"
|
700
|
-
check_power_floated(LongDecimal("0.0000000000000000000000000000000000000000000000000000000000000000002450257484405715360000000000000000097614149083200000000000000000000000972196"),
|
701
|
-
LongDecimal("-1.00000008600000184900000000000000000000000000000000000000012640000543520000000000000000000013300000571900000000000000399424000000000000000000000000000840560000000000000000000000000000442225"),
|
702
|
-
3)
|
703
|
-
puts "r"
|
704
|
-
check_power_floated(LongDecimal("0.00000000000000000000000000000000000000000000000000000000000000000000367236000000000000000093202800000000000000005914074196000000000000000058905400000000000000000000146689"),
|
705
|
-
LongDecimal("-1.000000000008800000000019360000000062800000000276320250000000001100000985960000000000007850000000000000015625"),
|
706
|
-
4)
|
707
|
-
puts "s"
|
708
|
-
check_power_floated(LongDecimal("0.000000000000000000000000000000000000000000000000000000000000000000002777290000000006513720000000003819240000000000000000000000000000100340800000000117667200000000000000000000000000000000000000000000906304"),
|
709
|
-
LongDecimal("-0.5773502691896257645091447198050641552797247036332110311421498194545129249630222981047763195372146430879281215100223411775138874331819083544781222838698051829302865547075365868655847179043571799566074987574406310154782766513220296853158689786573196010629608653145605201822170964422894732870490642190250948498852022304300879727510280657218553"),
|
710
|
-
23)
|
711
|
-
puts "s"
|
712
|
-
check_power_floated(LongDecimal("0.000000000000000000000000000000000000000000007350000295000915"),
|
713
|
-
LongDecimal("-1.000002193000861"),
|
714
|
-
2)
|
715
|
-
puts "u"
|
716
|
-
check_power_floated(LongDecimal("0.0000000086862400000000000000015172960006039360000000662596000527472000104976"),
|
717
|
-
LongDecimal("-0.999999999999999999999999999999999999999999999999999999999997169999999999996784999999999687000000000000000000000000000012013350000000027295350000002672874337500003018885000000146896669625999999845508318999984783776699499965759759873248317316431267825611053489338193758007138415641516991908731376997678345955102618540146326218008264916981179817214058767402196571"),
|
718
|
-
11)
|
719
|
-
puts "v"
|
720
|
-
check_power_floated(LongDecimal("0.00000000000000000000000000624000383000000000000000000000000000000000000000000000358"),
|
721
|
-
LongDecimal("-1.0000004600000000000000000000000000000004210"),
|
722
|
-
3)
|
723
|
-
puts "w"
|
724
|
-
check_power_floated(LongDecimal("0.00000000006236994468492015585972291475115698519825552824875948893004062366348813472156776148562881057978611940708477498267201430163921921918813918304834563518614088250202460271818014152969"),
|
725
|
-
LongDecimal("-21.81742422927144044215775880732087497227530694228658299334049542576403906256739064739549866577137008231569804502022381108724983114382624747999460445291671084230968250529511708947428208082234"),
|
726
|
-
6)
|
727
|
-
puts "x"
|
728
|
-
check_power_floated(LongDecimal("0.0000000000000000000000000000000000000000000000000000000000000000000035600000000928000000000000000450"),
|
729
|
-
LongDecimal("-0.70821529745042492917661444999959874487397062785764977666003279651340417551441776107007487983685090756343178115766012078677210548592741818458068450268168492334992979756923"),
|
730
|
-
13)
|
731
|
-
puts "y"
|
732
|
-
check_power_floated(LongDecimal("0.0000000000000000000000000000025900000000000000000000000000000000000000000022100000000000000000032"),
|
733
|
-
LongDecimal("-0.999943403203378688766215832183174473300891276419706031790088430934495839737458766990116492"),
|
734
|
-
4)
|
735
|
-
puts "z"
|
736
|
-
check_power_floated(LongDecimal("0.002658925294303146195800785280451092866235470739838791730450519159432915"),
|
737
|
-
LongDecimal("-87.0000000000000008330000000000000000000000000000000000000000000000000000000000000000000000000092046"),
|
738
|
-
90)
|
739
|
-
puts "a"
|
740
|
-
check_power_floated(LongDecimal("0.0014814814814814814812905349794238683127818125285779606767229367555739725854802645575188374989810195213530274617178142875856830586369415448003164084698537116523550097"),
|
741
|
-
LongDecimal("-52.0000000000000000000000000000000000000000683000000000000000000238000000000228"),
|
742
|
-
25)
|
743
|
-
puts "b"
|
744
|
-
check_power_floated(LongDecimal("0.00000000000000000000047400000000000000000084700000892"),
|
745
|
-
LongDecimal("-17.000000001310000000000000000000000000000000000000000000000000002800000000000000217"),
|
746
|
-
56)
|
747
|
-
puts "c"
|
748
|
-
check_power_floated(LongDecimal("0.00000000000000000000005110000000000000000004800000000000000000000000000000163"),
|
749
|
-
LongDecimal("-37.000000009170000000000000000000000000000000000000000000000000000000000000055800048"),
|
750
|
-
21)
|
751
|
-
puts "d"
|
752
|
-
check_power_floated(LongDecimal("0.0000000000000000000000000000000000000000000000000000000000000000002450257484405715360000000000000000097614149083200000000000000000000000972196"),
|
753
|
-
LongDecimal("-1.00000008600000184900000000000000000000000000000000000000012640000543520000000000000000000013300000571900000000000000399424000000000000000000000000000840560000000000000000000000000000442225"),
|
754
|
-
3)
|
755
|
-
puts "e"
|
756
|
-
check_power_floated(LongDecimal("0.999999999999983820000000000052544300000001372125483999980457478288050051600649560171986452284020178492146835403829341250837967306416835643061512149984415283328897050537606939603101940467080257495289168053434691062993302374332577706782680685214083677104079828206433042861334386773091111658939537092356816922764138900649581031721453211835260155666851398044388924204855221543729490461274063089475188763279119570"),
|
757
|
-
LongDecimal("80321932.89024988628926432624765785135567744505377819122460049392916097399960142838065367057138986526363804"),
|
758
|
-
40)
|
759
|
-
puts "f"
|
760
|
-
check_power_floated(LongDecimal("0.999999999999999999999999999999998351999999999999983020000000000002036927999998210041974559999999997978335404004424810825925120045592892314014072707890311225042124730264194167337496376801852022987153782535008598977724682635285958668331865904517437818865287190004735483899633845078360662820274644903126498781970492928578903950"),
|
761
|
-
LongDecimal("24449877750611246943765281173.594132029339853300733454400081300326994697544849684064538112517261374573394648075725881734888526076256999828217542217625441301525934675012853453406806380262764050867999"),
|
762
|
-
5)
|
763
|
-
puts "g"
|
764
|
-
check_power_floated(LongDecimal("0.999999999999999862599981980000014159073713922242243328677707050386499779178242565766291900177208859765599761583988066205590104341111429059119646260524293805643133602429678974677397380813589741657940554009198199034562447106122960905140273768835224006261013069576237942279008951360618433986"),
|
765
|
-
LongDecimal("10266940451745.37987679671457905534956086166404546967839388790271998098584221166751699838745542116653920000125768690393028114699714286512441385099525"),
|
766
|
-
14)
|
767
|
-
puts "h"
|
768
|
-
check_power_floated(LongDecimal("0.999999999999999981500000000000000256687499999999996834187500000000036604706930449997823687754750325053502286291757658419972795166437108241085949094447949893401640711985948839881287077716265593625727522425306777978451009970778400655052736724232660803755458234164496101454557290134193942433026948513566480800350007916601440691706219670728270104113540"),
|
769
|
-
LongDecimal("41380294430118397.455148144857963343847598908617723236165122243380531570432704458595232182042029429597565318650987561380534985825811466980798564531839364855305381553585381037046185516421336524897364607404185776449463"),
|
770
|
-
26)
|
771
|
-
puts "i"
|
772
|
-
check_power_floated(LongDecimal("0.000000000000000000000000000000000000046500000000000015087"),
|
773
|
-
LongDecimal("-1.0000000037300000000000000000000000000000000000000000003924"),
|
774
|
-
23)
|
775
|
-
|
776
|
-
end
|
777
|
-
|
778
|
-
#
|
779
|
-
# test the calculation of the base-10-logarithm function
|
780
|
-
#
|
781
|
-
def test_log10
|
782
|
-
check_log10_floated(10**2000, 30)
|
783
|
-
check_log10_floated(100, 30)
|
784
|
-
check_log10_floated(1, 30)
|
785
|
-
check_log10_floated(0.01, 30)
|
786
|
-
check_log10_floated(1e-10, 30)
|
787
|
-
check_log10_floated(1e-90, 30)
|
788
|
-
check_log10_floated(1e-300, 30)
|
789
|
-
check_log10_floated(LongDecimal(1, 2000), 30)
|
790
|
-
|
791
|
-
check_log10_exact(10**2000, 2000, 30)
|
792
|
-
check_log10_exact(10**0, 0, 30)
|
793
|
-
check_log10_exact(10**1, 1, 30)
|
794
|
-
check_log10_exact(10**10, 10, 30)
|
795
|
-
|
796
|
-
# random tests that have failed
|
797
|
-
check_log10_floated(LongDecimal("587.00000000000000000095700000000000000000000000000000000000000000000000000000000000000000000001206"), 21)
|
798
|
-
check_log10_floated(LongDecimal("543.0000002480000900000000000000000000000000000000000000000000000000000000000000000000847"), 2)
|
799
|
-
check_log10_floated(LongDecimal("180.0000000000000000003570000000000000000000000000000000000000000000000577000000000000000000000000000637"), 2)
|
800
|
-
check_log10_floated(LongDecimal("0.0000000000000000000000000000000000000000180000000063000000000000000000000000000000000025"), 74)
|
801
|
-
check_log10_floated(LongDecimal("0.0000000000000000000000000006200000000000000000000000000000000000000000000000007940000015"), 74)
|
802
|
-
check_log10_floated(LongDecimal("0.00000000000000000000000000000000000000000032900000000000000000000233000000000000000000000000000000254"), 10)
|
803
|
-
check_log10_floated(LongDecimal("0.00000000000000000000000233000000094800000000000000000000000000000000000000000000000000000000000000682"), 100)
|
804
|
-
check_log10_floated(LongDecimal("0.000000000000000000000000000000000000097000000041500000000000000000784"), 97)
|
805
|
-
check_log10_floated(LongDecimal("185.000025300000000000000006320000000000000000000000000000737"), 27)
|
806
|
-
check_log10_floated(LongDecimal("0.00000000000000000000000000000302000000000000000000000000000000000000000000000000000000060673"), 100)
|
807
|
-
check_log10_floated(LongDecimal("442.000000000000045300000000000000000000000000000000000000000000000000000000000000000000000721000000000752"), 97)
|
808
|
-
check_log10_floated(LongDecimal("0.001030927835051546391752577284408545010096715910298651428936221023301883588097777204212461151695109779555577162172"), 62)
|
809
|
-
|
810
|
-
end
|
811
|
-
|
812
|
-
#
|
813
|
-
# test the calculation of the base-10-logarithm function
|
814
|
-
#
|
815
|
-
def test_log2
|
816
|
-
check_log2_floated(10**2000, 30)
|
817
|
-
check_log2_floated(2**2000, 30)
|
818
|
-
check_log2_floated(100, 30)
|
819
|
-
check_log2_floated(1, 30)
|
820
|
-
check_log2_floated(0.01, 30)
|
821
|
-
check_log2_floated(1e-10, 30)
|
822
|
-
check_log2_floated(1e-90, 30)
|
823
|
-
check_log2_floated(1e-300, 30)
|
824
|
-
check_log2_floated(LongDecimal(1, 2000), 30)
|
825
|
-
|
826
|
-
check_log2_exact(2**2000, 2000, 30)
|
827
|
-
check_log2_exact(2**0, 0, 30)
|
828
|
-
check_log2_exact(2**1, 1, 30)
|
829
|
-
check_log2_exact(2**10, 10, 30)
|
830
|
-
|
831
|
-
# random tests that have failed
|
832
|
-
check_log2_floated(LongDecimal("341.00000739000000000000000000000000000000000000000000000000000000000000171"), 3)
|
833
|
-
check_log2_floated(LongDecimal("504.00000000000000000000000000000000000000000000000000000000000000000000000000000000000327400000000000828"), 1)
|
834
|
-
check_log2_floated(LongDecimal("0.0033222591362126245847176079734219269102990032888157967351353737817463383406363175903135730345286354858609181999523961456225622835123748782987926188031081"), 48)
|
835
|
-
check_log2_floated(LongDecimal("0.000802000000000000000000197000000000000000000000302"), 84)
|
836
|
-
check_log2_floated(LongDecimal("0.00000000000000000000000000000000000000000000000000000000000000000000000452000000000069480"), 3)
|
837
|
-
check_log2_floated(LongDecimal("0.0000000000000000000000000000000000000000000000000000930000000000000000000000000983000000000000300"), 61)
|
838
|
-
check_log2_floated(LongDecimal("0.000000000000000000000000000000000000000000000000000000000086000133000000000000000000000000947"), 106)
|
839
|
-
check_log2_floated(LongDecimal("0.00000000000000000000000000000276000000000000000000000000000000000008560000000000000000000000000000161"), 81)
|
840
|
-
|
841
|
-
end
|
842
|
-
|
843
250
|
#
|
844
251
|
# test the calculation of the base-x-logarithm of sqrt(x)
|
845
252
|
#
|
@@ -848,21 +255,13 @@ class TestLongDecimal_class < RUNIT::TestCase
|
|
848
255
|
n = 30
|
849
256
|
m = 5
|
850
257
|
xe = LongMath.sqrt(LongMath.exp(1, 2*n), n)
|
851
|
-
x2 = LongMath.sqrt(2, n)
|
852
|
-
x10 = LongMath.sqrt(10, n)
|
853
258
|
|
854
259
|
(2*m).times do |i|
|
855
260
|
check_log_floated(xe, n+m-i)
|
856
|
-
check_log2_floated(x2, n+m-i)
|
857
|
-
check_log10_floated(x10, n+m-i)
|
858
261
|
end
|
859
262
|
|
860
263
|
ye = check_log_floated(xe, n)
|
861
264
|
assert((ye*2).one?, "xe=#{xe} ye=#{ye}")
|
862
|
-
y2 = check_log2_floated(x2, n)
|
863
|
-
assert((y2*2).one?, "xe=#{x2} ye=#{y2}")
|
864
|
-
y10 = check_log10_floated(x10, n)
|
865
|
-
assert((y10*2).one?, "xe=#{x10} ye=#{y10}")
|
866
265
|
|
867
266
|
end
|
868
267
|
|