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
@@ -0,0 +1,645 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# testlongdecimal.rb -- runit test for long-decimal.rb
|
4
|
+
#
|
5
|
+
# CVS-ID: $Header: /var/cvs/long-decimal/long-decimal/test/testlongdecimal-extra.rb,v 1.1 2007/08/19 19:25:59 bk1 Exp $
|
6
|
+
# CVS-Label: $Name: ALPHA_01_03 $
|
7
|
+
# Author: $Author: bk1 $ (Karl Brodowsky)
|
8
|
+
#
|
9
|
+
|
10
|
+
require "runit/testcase"
|
11
|
+
require "runit/cui/testrunner"
|
12
|
+
require "runit/testsuite"
|
13
|
+
|
14
|
+
load "lib/long-decimal.rb"
|
15
|
+
load "lib/long-decimal-extra.rb"
|
16
|
+
load "test/testlongdeclib.rb"
|
17
|
+
|
18
|
+
#
|
19
|
+
# test class for LongDecimal and LongDecimalQuot
|
20
|
+
#
|
21
|
+
class TestLongDecimalExtra_class < RUNIT::TestCase
|
22
|
+
include TestLongDecHelper
|
23
|
+
|
24
|
+
@RCS_ID='-$Id: testlongdecimal-extra.rb,v 1.1 2007/08/19 19:25:59 bk1 Exp $-'
|
25
|
+
|
26
|
+
#
|
27
|
+
# test exp2 of LongMath
|
28
|
+
#
|
29
|
+
def test_exp2
|
30
|
+
10.times do |i|
|
31
|
+
n = (i*i+i)/2
|
32
|
+
x = LongDecimal(n, 3*i)+LongMath.pi(20)
|
33
|
+
check_exp2_floated(x, n)
|
34
|
+
|
35
|
+
y = LongMath.exp2(x, n)
|
36
|
+
yy = LongMath.exp2(x, n + 5)
|
37
|
+
assert_equal(yy.round_to_scale(y.scale, LongDecimal::ROUND_HALF_DOWN), y, "x=#{x} y=#{y} yy=#{yy}")
|
38
|
+
z = LongMath.power(2, x, n)
|
39
|
+
assert_equal(z, y, "exp2 x=#{x} y=#{y} z=#{z} i=#{i} n=#{n}")
|
40
|
+
end
|
41
|
+
|
42
|
+
# random tests that have failed previously
|
43
|
+
check_exp2_floated(LongDecimal("-0.00147492625237084606064197462823289474038138852346725504592707365251736299180323394082648207114993022483949313246714392730651107673327728615912046468517225938833913598854936005"), 20)
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
#
|
48
|
+
# test the calculation of the exponential function where result is
|
49
|
+
# near zero
|
50
|
+
#
|
51
|
+
def test_exp2_near_zero
|
52
|
+
|
53
|
+
x = LongDecimal(1, 100)
|
54
|
+
y = LongMath.log2(x, 100)
|
55
|
+
z = check_exp2_floated(y, 100)
|
56
|
+
assert_equal(x, z, "must be equal")
|
57
|
+
z = check_exp2_floated(y, 99)
|
58
|
+
assert(z.zero?, "must be zero")
|
59
|
+
z = check_exp2_floated(y * 100, 99)
|
60
|
+
assert(z.zero?, "must be zero")
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
#
|
65
|
+
# test exp10 of LongMath
|
66
|
+
#
|
67
|
+
def test_exp10
|
68
|
+
10.times do |i|
|
69
|
+
n = (i*i+i)/2
|
70
|
+
x = LongDecimal(n, 3*i)+LongMath.pi(20)
|
71
|
+
check_exp10_floated(x, n)
|
72
|
+
|
73
|
+
y = LongMath.exp10(x, n)
|
74
|
+
yy = LongMath.exp10(x, n + 5)
|
75
|
+
assert_equal(yy.round_to_scale(y.scale, LongDecimal::ROUND_HALF_DOWN), y, "x=#{x} y=#{y} yy=#{yy}")
|
76
|
+
z = LongMath.power(10, x, n)
|
77
|
+
assert_equal(z, y, "exp10 x=#{x} y=#{y} z=#{z} i=#{i} n=#{n}")
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
#
|
82
|
+
# test the calculation of the exponential function where result is
|
83
|
+
# near zero
|
84
|
+
#
|
85
|
+
def test_exp10_near_zero
|
86
|
+
|
87
|
+
x = LongDecimal(1, 100)
|
88
|
+
y = LongMath.log10(x, 100)
|
89
|
+
z = check_exp10_floated(y, 100)
|
90
|
+
assert_equal(x, z, "must be equal")
|
91
|
+
z = check_exp10_floated(y, 99)
|
92
|
+
assert(z.zero?, "must be zero")
|
93
|
+
z = check_exp10_floated(y * 100, 99)
|
94
|
+
assert(z.zero?, "must be zero")
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
#
|
99
|
+
# test LongMath.power for bases that can be expressed as integer
|
100
|
+
#
|
101
|
+
def test_lm_power_xint
|
102
|
+
|
103
|
+
xx = LongMath.log(3, 40)
|
104
|
+
pi = LongMath.pi(40)
|
105
|
+
sq = LongMath.sqrt(5, 40)
|
106
|
+
|
107
|
+
check_power_xint(2, 700.01, 10)
|
108
|
+
check_power_xint(2, 100.001, 10)
|
109
|
+
check_power_xint(2, 1.000000001, 10)
|
110
|
+
check_power_xint(2, 0.01, 10)
|
111
|
+
check_power_xint(2, 1e-10, 10)
|
112
|
+
check_power_xint(2, 1e-90, 10)
|
113
|
+
check_power_xint(2, 0, 10)
|
114
|
+
check_power_xint(2, -1.000000001, 10)
|
115
|
+
check_power_xint(2, -100.001, 10)
|
116
|
+
check_power_xint(2, -700.01, 10)
|
117
|
+
check_power_xint(2, xx, 10)
|
118
|
+
check_power_xint(2, pi, 10)
|
119
|
+
check_power_xint(2, sq, 10)
|
120
|
+
|
121
|
+
check_power_xint(10, 308.01, 10)
|
122
|
+
check_power_xint(10, 100.001, 10)
|
123
|
+
check_power_xint(10, 1.000000001, 10)
|
124
|
+
check_power_xint(10, 0.01, 10)
|
125
|
+
check_power_xint(10, 1e-10, 10)
|
126
|
+
check_power_xint(10, 1e-90, 10)
|
127
|
+
check_power_xint(10, 0, 10)
|
128
|
+
check_power_xint(10, -1.000000001, 10)
|
129
|
+
check_power_xint(10, -100.001, 10)
|
130
|
+
check_power_xint(10, -308.01, 10)
|
131
|
+
check_power_xint(10, xx, 10)
|
132
|
+
check_power_xint(10, pi, 10)
|
133
|
+
check_power_xint(10, sq, 10)
|
134
|
+
|
135
|
+
check_power_xint(2, 700.01, 100)
|
136
|
+
check_power_xint(2, 100.001, 100)
|
137
|
+
check_power_xint(2, 1.000000001, 100)
|
138
|
+
check_power_xint(2, 0.01, 100)
|
139
|
+
check_power_xint(2, 1e-10, 100)
|
140
|
+
check_power_xint(2, 1e-90, 100)
|
141
|
+
check_power_xint(2, 0, 100)
|
142
|
+
check_power_xint(2, -1.000000001, 100)
|
143
|
+
check_power_xint(2, -100.001, 100)
|
144
|
+
check_power_xint(2, -700.01, 100)
|
145
|
+
check_power_xint(2, xx, 100)
|
146
|
+
check_power_xint(2, pi, 100)
|
147
|
+
check_power_xint(2, sq, 100)
|
148
|
+
|
149
|
+
check_power_xint(10, 308.01, 100)
|
150
|
+
check_power_xint(10, 100.001, 100)
|
151
|
+
check_power_xint(10, 1.000000001, 100)
|
152
|
+
check_power_xint(10, 0.01, 100)
|
153
|
+
check_power_xint(10, 1e-10, 100)
|
154
|
+
check_power_xint(10, 1e-90, 100)
|
155
|
+
check_power_xint(10, 0, 100)
|
156
|
+
check_power_xint(10, -1.000000001, 100)
|
157
|
+
check_power_xint(10, -100.001, 100)
|
158
|
+
check_power_xint(10, -308.01, 100)
|
159
|
+
check_power_xint(10, xx, 100)
|
160
|
+
check_power_xint(10, pi, 100)
|
161
|
+
check_power_xint(10, sq, 100)
|
162
|
+
|
163
|
+
check_power_xint(2, 700.01, 40)
|
164
|
+
check_power_xint(2, 100.001, 40)
|
165
|
+
check_power_xint(2, 1.000000001, 40)
|
166
|
+
check_power_xint(2, 0.01, 40)
|
167
|
+
check_power_xint(2, 1e-10, 40)
|
168
|
+
check_power_xint(2, 1e-90, 40)
|
169
|
+
check_power_xint(2, 0, 40)
|
170
|
+
check_power_xint(2, -1.000000001, 40)
|
171
|
+
check_power_xint(2, -100.001, 40)
|
172
|
+
check_power_xint(2, -700.01, 40)
|
173
|
+
check_power_xint(2, xx, 40)
|
174
|
+
check_power_xint(2, pi, 40)
|
175
|
+
check_power_xint(2, sq, 40)
|
176
|
+
|
177
|
+
check_power_xint(10, 308.01, 40)
|
178
|
+
check_power_xint(10, 100.001, 40)
|
179
|
+
check_power_xint(10, 1.000000001, 40)
|
180
|
+
check_power_xint(10, 0.01, 40)
|
181
|
+
check_power_xint(10, 1e-10, 40)
|
182
|
+
check_power_xint(10, 1e-90, 40)
|
183
|
+
check_power_xint(10, 0, 40)
|
184
|
+
check_power_xint(10, -1.000000001, 40)
|
185
|
+
check_power_xint(10, -100.001, 40)
|
186
|
+
check_power_xint(10, -308.01, 40)
|
187
|
+
check_power_xint(10, xx, 40)
|
188
|
+
check_power_xint(10, pi, 40)
|
189
|
+
check_power_xint(10, sq, 40)
|
190
|
+
|
191
|
+
end
|
192
|
+
|
193
|
+
#
|
194
|
+
# test LongMath.power for bases that can be expressed as integer
|
195
|
+
#
|
196
|
+
def test_lm_power_yint
|
197
|
+
|
198
|
+
xx = LongMath.log(3, 40)
|
199
|
+
pi = LongMath.pi(40)
|
200
|
+
sq = LongMath.sqrt(5, 40)
|
201
|
+
|
202
|
+
check_power_yint(xx, 400, 10)
|
203
|
+
check_power_yint(xx, 100, 10)
|
204
|
+
check_power_yint(xx, 1, 10)
|
205
|
+
check_power_yint(xx, 0, 10)
|
206
|
+
check_power_yint(xx, -1, 10)
|
207
|
+
check_power_yint(xx, -100, 10)
|
208
|
+
check_power_yint(xx, -400, 10)
|
209
|
+
|
210
|
+
check_power_yint(pi, 400, 10)
|
211
|
+
check_power_yint(pi, 100, 10)
|
212
|
+
check_power_yint(pi, 1, 10)
|
213
|
+
check_power_yint(pi, 0, 10)
|
214
|
+
check_power_yint(pi, -1, 10)
|
215
|
+
check_power_yint(pi, -100, 10)
|
216
|
+
check_power_yint(pi, -400, 10)
|
217
|
+
|
218
|
+
check_power_yint(sq, 400, 10)
|
219
|
+
check_power_yint(sq, 100, 10)
|
220
|
+
check_power_yint(sq, 1, 10)
|
221
|
+
check_power_yint(sq, 0, 10)
|
222
|
+
check_power_yint(sq, -1, 10)
|
223
|
+
check_power_yint(sq, -100, 10)
|
224
|
+
check_power_yint(sq, -400, 10)
|
225
|
+
|
226
|
+
check_power_yint(xx, 400, 100)
|
227
|
+
check_power_yint(xx, 100, 100)
|
228
|
+
check_power_yint(xx, 1, 100)
|
229
|
+
check_power_yint(xx, 0, 100)
|
230
|
+
check_power_yint(xx, -1, 100)
|
231
|
+
check_power_yint(xx, -100, 100)
|
232
|
+
check_power_yint(xx, -400, 100)
|
233
|
+
|
234
|
+
check_power_yint(pi, 400, 100)
|
235
|
+
check_power_yint(pi, 100, 100)
|
236
|
+
check_power_yint(pi, 1, 100)
|
237
|
+
check_power_yint(pi, 0, 100)
|
238
|
+
check_power_yint(pi, -1, 100)
|
239
|
+
check_power_yint(pi, -100, 100)
|
240
|
+
check_power_yint(pi, -400, 100)
|
241
|
+
|
242
|
+
check_power_yint(sq, 400, 100)
|
243
|
+
check_power_yint(sq, 100, 100)
|
244
|
+
check_power_yint(sq, 1, 100)
|
245
|
+
check_power_yint(sq, 0, 100)
|
246
|
+
check_power_yint(sq, -1, 100)
|
247
|
+
check_power_yint(sq, -100, 100)
|
248
|
+
check_power_yint(sq, -400, 100)
|
249
|
+
|
250
|
+
check_power_yint(xx, 400, 40)
|
251
|
+
check_power_yint(xx, 100, 40)
|
252
|
+
check_power_yint(xx, 1, 40)
|
253
|
+
check_power_yint(xx, 0, 40)
|
254
|
+
check_power_yint(xx, -1, 40)
|
255
|
+
check_power_yint(xx, -100, 40)
|
256
|
+
check_power_yint(xx, -400, 40)
|
257
|
+
|
258
|
+
check_power_yint(pi, 400, 40)
|
259
|
+
check_power_yint(pi, 100, 40)
|
260
|
+
check_power_yint(pi, 1, 40)
|
261
|
+
check_power_yint(pi, 0, 40)
|
262
|
+
check_power_yint(pi, -1, 40)
|
263
|
+
check_power_yint(pi, -100, 40)
|
264
|
+
check_power_yint(pi, -400, 40)
|
265
|
+
|
266
|
+
check_power_yint(sq, 400, 40)
|
267
|
+
check_power_yint(sq, 100, 40)
|
268
|
+
check_power_yint(sq, 1, 40)
|
269
|
+
check_power_yint(sq, 0, 40)
|
270
|
+
check_power_yint(sq, -1, 40)
|
271
|
+
check_power_yint(sq, -100, 40)
|
272
|
+
check_power_yint(sq, -400, 40)
|
273
|
+
|
274
|
+
end
|
275
|
+
|
276
|
+
#
|
277
|
+
# test LongMath.power for bases that can be expressed as integer
|
278
|
+
#
|
279
|
+
def test_lm_power_yhalfint
|
280
|
+
|
281
|
+
xx = LongMath.log(3, 40)
|
282
|
+
pi = LongMath.pi(40)
|
283
|
+
sq = LongMath.sqrt(5, 40)
|
284
|
+
|
285
|
+
check_power_yhalfint(xx, 801, 10)
|
286
|
+
check_power_yhalfint(xx, 799, 10)
|
287
|
+
check_power_yhalfint(xx, 201, 10)
|
288
|
+
check_power_yhalfint(xx, 3, 10)
|
289
|
+
check_power_yhalfint(xx, 1, 10)
|
290
|
+
check_power_yhalfint(xx, -1, 10)
|
291
|
+
check_power_yhalfint(xx, -201, 10)
|
292
|
+
check_power_yhalfint(xx, -799, 10)
|
293
|
+
check_power_yhalfint(xx, -801, 10)
|
294
|
+
|
295
|
+
check_power_yhalfint(pi, 801, 10)
|
296
|
+
check_power_yhalfint(pi, 799, 10)
|
297
|
+
check_power_yhalfint(pi, 201, 10)
|
298
|
+
check_power_yhalfint(pi, 3, 10)
|
299
|
+
check_power_yhalfint(pi, 1, 10)
|
300
|
+
check_power_yhalfint(pi, -1, 10)
|
301
|
+
check_power_yhalfint(pi, -201, 10)
|
302
|
+
check_power_yhalfint(pi, -799, 10)
|
303
|
+
check_power_yhalfint(pi, -801, 10)
|
304
|
+
|
305
|
+
check_power_yhalfint(sq, 801, 10)
|
306
|
+
check_power_yhalfint(sq, 799, 10)
|
307
|
+
check_power_yhalfint(sq, 201, 10)
|
308
|
+
check_power_yhalfint(sq, 3, 10)
|
309
|
+
check_power_yhalfint(sq, 1, 10)
|
310
|
+
check_power_yhalfint(sq, -1, 10)
|
311
|
+
check_power_yhalfint(sq, -201, 10)
|
312
|
+
check_power_yhalfint(sq, -799, 10)
|
313
|
+
check_power_yhalfint(sq, -801, 10)
|
314
|
+
|
315
|
+
check_power_yhalfint(xx, 801, 40)
|
316
|
+
check_power_yhalfint(xx, 799, 40)
|
317
|
+
check_power_yhalfint(xx, 201, 40)
|
318
|
+
check_power_yhalfint(xx, 3, 40)
|
319
|
+
check_power_yhalfint(xx, 1, 40)
|
320
|
+
check_power_yhalfint(xx, -1, 40)
|
321
|
+
check_power_yhalfint(xx, -201, 40)
|
322
|
+
check_power_yhalfint(xx, -799, 40)
|
323
|
+
check_power_yhalfint(xx, -801, 40)
|
324
|
+
|
325
|
+
check_power_yhalfint(pi, 801, 40)
|
326
|
+
check_power_yhalfint(pi, 799, 40)
|
327
|
+
check_power_yhalfint(pi, 201, 40)
|
328
|
+
check_power_yhalfint(pi, 3, 40)
|
329
|
+
check_power_yhalfint(pi, 1, 40)
|
330
|
+
check_power_yhalfint(pi, -1, 40)
|
331
|
+
check_power_yhalfint(pi, -201, 40)
|
332
|
+
check_power_yhalfint(pi, -799, 40)
|
333
|
+
check_power_yhalfint(pi, -801, 40)
|
334
|
+
|
335
|
+
check_power_yhalfint(sq, 801, 40)
|
336
|
+
check_power_yhalfint(sq, 799, 40)
|
337
|
+
check_power_yhalfint(sq, 201, 40)
|
338
|
+
check_power_yhalfint(sq, 3, 40)
|
339
|
+
check_power_yhalfint(sq, 1, 40)
|
340
|
+
check_power_yhalfint(sq, -1, 40)
|
341
|
+
check_power_yhalfint(sq, -201, 40)
|
342
|
+
check_power_yhalfint(sq, -799, 40)
|
343
|
+
check_power_yhalfint(sq, -801, 40)
|
344
|
+
|
345
|
+
end
|
346
|
+
|
347
|
+
#
|
348
|
+
# test LongMath.power with non-LongDecimal arguments
|
349
|
+
#
|
350
|
+
def test_non_ld_power
|
351
|
+
xi = 77
|
352
|
+
yi = 88
|
353
|
+
zi = LongMath.power(xi, yi, 35)
|
354
|
+
wi = (LongMath.log(zi, 40) / LongMath.log(xi, 40)).round_to_scale(30, LongMath::ROUND_HALF_EVEN)
|
355
|
+
assert(wi.is_int?, "wi=#{wi} not int (zi=#{zi})")
|
356
|
+
assert_equal(yi, wi.to_i, "zi=#{zi} wi=#{wi}")
|
357
|
+
zj = LongMath.power_internal(xi, yi, 35)
|
358
|
+
assert_equal(zi, zj, "internal power should yield the same result zi=#{zi} zj=#{zj}")
|
359
|
+
|
360
|
+
xf = 77.0
|
361
|
+
yf = 88.0
|
362
|
+
zf = LongMath.power(xf, yf, 35)
|
363
|
+
wf = (LongMath.log(zf, 40) / LongMath.log(xf, 40)).round_to_scale(30, LongMath::ROUND_HALF_EVEN)
|
364
|
+
assert(wf.is_int?, "wf=#{wf} not int (zf=#{zf} wi=#{wi} zi=#{zi}")
|
365
|
+
assert_equal(yf, wf.to_i, "yf=#{yf} wf=#{yf}")
|
366
|
+
|
367
|
+
xr = Rational(224, 225)
|
368
|
+
yr = Rational(168, 169)
|
369
|
+
zr = LongMath.power(xr, yr, 35)
|
370
|
+
wr = (LongMath.log(zr, 40) / LongMath.log(xr, 40)).round_to_scale(30, LongMath::ROUND_HALF_EVEN)
|
371
|
+
assert((yr-wr).abs <= wr.unit, "wr-yr")
|
372
|
+
end
|
373
|
+
|
374
|
+
#
|
375
|
+
# test the calculation of the power-function of LongMath
|
376
|
+
#
|
377
|
+
def test_lm_power
|
378
|
+
check_power_floated(1.001, 1.001, 10)
|
379
|
+
check_power_floated(1.001, 2.001, 10)
|
380
|
+
check_power_floated(2.001, 1.001, 10)
|
381
|
+
check_power_floated(2.001, 2.001, 10)
|
382
|
+
check_power_floated(100.001, 10.001, 10)
|
383
|
+
check_power_floated(10.001, 100.001, 10)
|
384
|
+
check_power_floated(10.001, 100.001, 100)
|
385
|
+
check_power_floated(1e-20, 1.01, 19)
|
386
|
+
check_power_floated(1.01, 1e-20, 19)
|
387
|
+
check_power_floated(1e-20, 1.01, 20)
|
388
|
+
check_power_floated(1.01, 1e-20, 20)
|
389
|
+
check_power_floated(1e-20, 1.01, 21)
|
390
|
+
check_power_floated(1.01, 1e-20, 21)
|
391
|
+
puts "done (1.01, 1e-20, 21)"
|
392
|
+
|
393
|
+
check_power_floated(1.001, -1.001, 10)
|
394
|
+
check_power_floated(1.001, -2.001, 10)
|
395
|
+
check_power_floated(2.001, -1.001, 10)
|
396
|
+
check_power_floated(2.001, -2.001, 10)
|
397
|
+
check_power_floated(100.001, -10.001, 10)
|
398
|
+
check_power_floated(10.001, -100.001, 10)
|
399
|
+
check_power_floated(1e-20, -1.01, 19)
|
400
|
+
check_power_floated(1.01, -1e-20, 19)
|
401
|
+
check_power_floated(1e-20, -1.01, 20)
|
402
|
+
check_power_floated(1.01, -1e-20, 20)
|
403
|
+
check_power_floated(1e-20, -1.01, 21)
|
404
|
+
check_power_floated(1.01, -1e-20, 21)
|
405
|
+
puts "done (1.01, -1e-20, 21)"
|
406
|
+
|
407
|
+
# random tests that have failed
|
408
|
+
check_power_floated(LongDecimal("0.000000000077517987624900000000000000000000000000000000000000000000000000000000000000000000000000000014809051260000000000000000000000000000000000000000000000000000000000000000000000000000000000707281"),
|
409
|
+
LongDecimal("26.627053911388694974442854299008649887946027550330988420533923061901183724914978160564862753777080769340"),
|
410
|
+
29)
|
411
|
+
puts "a"
|
412
|
+
check_power_floated(LongDecimal("1.000000000000000151000000000000000000000000000000000000000000000000000000000000057800000000205"),
|
413
|
+
LongDecimal("-680.0000000000000000000013100000000000000000000000000000000000000165000000000000000000234"),
|
414
|
+
26)
|
415
|
+
puts "b"
|
416
|
+
check_power_floated(LongDecimal("1.0000000000000000000000000000000000000000000068000000000853000000000926"),
|
417
|
+
LongDecimal("-536.000000000086100000000000000000000000000019200000000000000000000000000000000000000000000000166"),
|
418
|
+
49)
|
419
|
+
puts "c"
|
420
|
+
check_power_floated(LongDecimal("1.0000000000000000049000000000002090000000000447"),
|
421
|
+
LongDecimal("-328.00000000000000000000000000000000567000000000000000026600000000000000000000000679"),
|
422
|
+
24)
|
423
|
+
puts "d"
|
424
|
+
check_power_floated(LongDecimal("1.0000000000000000000003580000000000000000000000376238"),
|
425
|
+
LongDecimal("-359.0000000003910721000000000000000000000000000000000000000000000000000000000000000000000000479"),
|
426
|
+
39)
|
427
|
+
puts "e"
|
428
|
+
check_power_floated(LongDecimal("1.000000000000000000000032000000001500000000000000000000439"),
|
429
|
+
LongDecimal("-252.00000000000000025500000000000176907"),
|
430
|
+
39)
|
431
|
+
puts "f"
|
432
|
+
check_power_floated(LongDecimal("1.0000000000000008590000521000000000000621"),
|
433
|
+
LongDecimal("-135.0000000000000000000000000000000000000000000000000000000074400000000000000000000000000321"),
|
434
|
+
50)
|
435
|
+
puts "g"
|
436
|
+
check_power_floated(LongDecimal("1.000000000000000151000000000000000000000000000000000000000000000000000000000000057800000000205"),
|
437
|
+
LongDecimal("-680.0000000000000000000013100000000000000000000000000000000000000165000000000000000000234"),
|
438
|
+
26)
|
439
|
+
puts "h"
|
440
|
+
check_power_floated(LongDecimal("1.02350000000000000000000356000000000000000000000000000000000000000000000000000000000104"),
|
441
|
+
LongDecimal("-971.0000000000000000055400000000000000000000000000000000000000000000000000040900000000000000000000000603"),
|
442
|
+
45)
|
443
|
+
puts "i"
|
444
|
+
check_power_floated(LongDecimal("1.0023800000000000000000000000000000000000000000000000000000000000265000000000000000000000000000000453"),
|
445
|
+
LongDecimal("-277.000000000000000000000000000000000000000000000000000000000000113000000000000000000041400000294"),
|
446
|
+
22)
|
447
|
+
puts "j"
|
448
|
+
check_power_floated(LongDecimal("0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003422250001093950095910422515315300670761"),
|
449
|
+
LongDecimal("-0.99999999999999999999999999999999999999999999999999997909999999999999999999999999667999957000000000000000065521500000000000000000000020816402696099999999999997719321110428280027729999999129874367303020000000000071412895105695789681563000036363932570289984431712381817869482773696988055442648559706239710901091550702341077381290973316336980640165855210736680"),
|
450
|
+
46)
|
451
|
+
puts "k"
|
452
|
+
check_power_floated(LongDecimal("0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000049273899694369"),
|
453
|
+
LongDecimal("-0.99999999999999999999999999999999999999988899963450000000000000000000000000000001847988671170038537499999999999999999999658146648184996349480690906250000000000066400422857493760370353798820585648437488207957808220483456569835670219978619056054192244103752969215743872596800486621906638928959243058783356441503226136251748249991020724187893339868"),
|
454
|
+
40)
|
455
|
+
puts "l"
|
456
|
+
check_power_floated(LongDecimal("0.0000000000000000000000000000003868840000000000000000000328416000000000000000000006969600000000000000000000000000000059338800000000000000000002518560000000000000000000000000000000000000000000000000000000227529"),
|
457
|
+
LongDecimal("-0.999999999999999999999999999999999999999999999999999998264999999999999999999999999999616741000000000000000004515337500000000000000000000001994863094999999999999986943149282831191620999999999993077825060350000000000033980453035745280148525000000024019946927993617107497210600671335038418031107762499920991889855598841096454678838495791189026426859181655270271342"),
|
458
|
+
31)
|
459
|
+
puts "m"
|
460
|
+
check_power_floated(LongDecimal("0.0000000000000000000000000000000000000000000000435600000000000000000000000000000000000000000000000006204000000075240000000000000000000000000000000000000022090000000535800000003249"),
|
461
|
+
LongDecimal("-4.50377349099168904759987513420506734335755704389619751192197520413005925604849718759451665302464588879636922713303481423460050066204079523260315868192642742903330525895063299416"),
|
462
|
+
20)
|
463
|
+
puts "n"
|
464
|
+
check_power_floated(LongDecimal("0.0000000000000000000000000000700720943029391693947940220429504569709269190190365416713568"),
|
465
|
+
LongDecimal("-6.633249580710799698229865473341373367854177091179010213018664944871230"),
|
466
|
+
7)
|
467
|
+
puts "o"
|
468
|
+
check_power_floated(LongDecimal("0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000816700000697"),
|
469
|
+
LongDecimal("-0.58685446009389671361502347417840375586854460093896713614906034406753510106019528753113359342280707917300359276157963863070992095386428055722936293804476401957909668625460628698383384886591034139"),
|
470
|
+
36)
|
471
|
+
puts "p"
|
472
|
+
check_power_floated(LongDecimal("0.000000000000000000000000000000000000046500000000000015087"),
|
473
|
+
LongDecimal("-1.0000000037300000000000000000000000000000000000000000003924"),
|
474
|
+
3)
|
475
|
+
puts "q"
|
476
|
+
check_power_floated(LongDecimal("0.0000000000000000000000000000000000000000000000000000000000000000002450257484405715360000000000000000097614149083200000000000000000000000972196"),
|
477
|
+
LongDecimal("-1.00000008600000184900000000000000000000000000000000000000012640000543520000000000000000000013300000571900000000000000399424000000000000000000000000000840560000000000000000000000000000442225"),
|
478
|
+
3)
|
479
|
+
puts "r"
|
480
|
+
check_power_floated(LongDecimal("0.00000000000000000000000000000000000000000000000000000000000000000000367236000000000000000093202800000000000000005914074196000000000000000058905400000000000000000000146689"),
|
481
|
+
LongDecimal("-1.000000000008800000000019360000000062800000000276320250000000001100000985960000000000007850000000000000015625"),
|
482
|
+
4)
|
483
|
+
puts "s"
|
484
|
+
check_power_floated(LongDecimal("0.000000000000000000000000000000000000000000000000000000000000000000002777290000000006513720000000003819240000000000000000000000000000100340800000000117667200000000000000000000000000000000000000000000906304"),
|
485
|
+
LongDecimal("-0.5773502691896257645091447198050641552797247036332110311421498194545129249630222981047763195372146430879281215100223411775138874331819083544781222838698051829302865547075365868655847179043571799566074987574406310154782766513220296853158689786573196010629608653145605201822170964422894732870490642190250948498852022304300879727510280657218553"),
|
486
|
+
23)
|
487
|
+
puts "s"
|
488
|
+
check_power_floated(LongDecimal("0.000000000000000000000000000000000000000000007350000295000915"),
|
489
|
+
LongDecimal("-1.000002193000861"),
|
490
|
+
2)
|
491
|
+
puts "u"
|
492
|
+
check_power_floated(LongDecimal("0.0000000086862400000000000000015172960006039360000000662596000527472000104976"),
|
493
|
+
LongDecimal("-0.999999999999999999999999999999999999999999999999999999999997169999999999996784999999999687000000000000000000000000000012013350000000027295350000002672874337500003018885000000146896669625999999845508318999984783776699499965759759873248317316431267825611053489338193758007138415641516991908731376997678345955102618540146326218008264916981179817214058767402196571"),
|
494
|
+
11)
|
495
|
+
puts "v"
|
496
|
+
check_power_floated(LongDecimal("0.00000000000000000000000000624000383000000000000000000000000000000000000000000000358"),
|
497
|
+
LongDecimal("-1.0000004600000000000000000000000000000004210"),
|
498
|
+
3)
|
499
|
+
puts "w"
|
500
|
+
check_power_floated(LongDecimal("0.00000000006236994468492015585972291475115698519825552824875948893004062366348813472156776148562881057978611940708477498267201430163921921918813918304834563518614088250202460271818014152969"),
|
501
|
+
LongDecimal("-21.81742422927144044215775880732087497227530694228658299334049542576403906256739064739549866577137008231569804502022381108724983114382624747999460445291671084230968250529511708947428208082234"),
|
502
|
+
6)
|
503
|
+
puts "x"
|
504
|
+
check_power_floated(LongDecimal("0.0000000000000000000000000000000000000000000000000000000000000000000035600000000928000000000000000450"),
|
505
|
+
LongDecimal("-0.70821529745042492917661444999959874487397062785764977666003279651340417551441776107007487983685090756343178115766012078677210548592741818458068450268168492334992979756923"),
|
506
|
+
13)
|
507
|
+
puts "y"
|
508
|
+
check_power_floated(LongDecimal("0.0000000000000000000000000000025900000000000000000000000000000000000000000022100000000000000000032"),
|
509
|
+
LongDecimal("-0.999943403203378688766215832183174473300891276419706031790088430934495839737458766990116492"),
|
510
|
+
4)
|
511
|
+
puts "z"
|
512
|
+
check_power_floated(LongDecimal("0.002658925294303146195800785280451092866235470739838791730450519159432915"),
|
513
|
+
LongDecimal("-87.0000000000000008330000000000000000000000000000000000000000000000000000000000000000000000000092046"),
|
514
|
+
90)
|
515
|
+
puts "a"
|
516
|
+
check_power_floated(LongDecimal("0.0014814814814814814812905349794238683127818125285779606767229367555739725854802645575188374989810195213530274617178142875856830586369415448003164084698537116523550097"),
|
517
|
+
LongDecimal("-52.0000000000000000000000000000000000000000683000000000000000000238000000000228"),
|
518
|
+
25)
|
519
|
+
puts "b"
|
520
|
+
check_power_floated(LongDecimal("0.00000000000000000000047400000000000000000084700000892"),
|
521
|
+
LongDecimal("-17.000000001310000000000000000000000000000000000000000000000000002800000000000000217"),
|
522
|
+
56)
|
523
|
+
puts "c"
|
524
|
+
check_power_floated(LongDecimal("0.00000000000000000000005110000000000000000004800000000000000000000000000000163"),
|
525
|
+
LongDecimal("-37.000000009170000000000000000000000000000000000000000000000000000000000000055800048"),
|
526
|
+
21)
|
527
|
+
puts "d"
|
528
|
+
check_power_floated(LongDecimal("0.0000000000000000000000000000000000000000000000000000000000000000002450257484405715360000000000000000097614149083200000000000000000000000972196"),
|
529
|
+
LongDecimal("-1.00000008600000184900000000000000000000000000000000000000012640000543520000000000000000000013300000571900000000000000399424000000000000000000000000000840560000000000000000000000000000442225"),
|
530
|
+
3)
|
531
|
+
puts "e"
|
532
|
+
check_power_floated(LongDecimal("0.999999999999983820000000000052544300000001372125483999980457478288050051600649560171986452284020178492146835403829341250837967306416835643061512149984415283328897050537606939603101940467080257495289168053434691062993302374332577706782680685214083677104079828206433042861334386773091111658939537092356816922764138900649581031721453211835260155666851398044388924204855221543729490461274063089475188763279119570"),
|
533
|
+
LongDecimal("80321932.89024988628926432624765785135567744505377819122460049392916097399960142838065367057138986526363804"),
|
534
|
+
40)
|
535
|
+
puts "f"
|
536
|
+
check_power_floated(LongDecimal("0.999999999999999999999999999999998351999999999999983020000000000002036927999998210041974559999999997978335404004424810825925120045592892314014072707890311225042124730264194167337496376801852022987153782535008598977724682635285958668331865904517437818865287190004735483899633845078360662820274644903126498781970492928578903950"),
|
537
|
+
LongDecimal("24449877750611246943765281173.594132029339853300733454400081300326994697544849684064538112517261374573394648075725881734888526076256999828217542217625441301525934675012853453406806380262764050867999"),
|
538
|
+
5)
|
539
|
+
puts "g"
|
540
|
+
check_power_floated(LongDecimal("0.999999999999999862599981980000014159073713922242243328677707050386499779178242565766291900177208859765599761583988066205590104341111429059119646260524293805643133602429678974677397380813589741657940554009198199034562447106122960905140273768835224006261013069576237942279008951360618433986"),
|
541
|
+
LongDecimal("10266940451745.37987679671457905534956086166404546967839388790271998098584221166751699838745542116653920000125768690393028114699714286512441385099525"),
|
542
|
+
14)
|
543
|
+
puts "h"
|
544
|
+
check_power_floated(LongDecimal("0.999999999999999981500000000000000256687499999999996834187500000000036604706930449997823687754750325053502286291757658419972795166437108241085949094447949893401640711985948839881287077716265593625727522425306777978451009970778400655052736724232660803755458234164496101454557290134193942433026948513566480800350007916601440691706219670728270104113540"),
|
545
|
+
LongDecimal("41380294430118397.455148144857963343847598908617723236165122243380531570432704458595232182042029429597565318650987561380534985825811466980798564531839364855305381553585381037046185516421336524897364607404185776449463"),
|
546
|
+
26)
|
547
|
+
puts "i"
|
548
|
+
check_power_floated(LongDecimal("0.000000000000000000000000000000000000046500000000000015087"),
|
549
|
+
LongDecimal("-1.0000000037300000000000000000000000000000000000000000003924"),
|
550
|
+
23)
|
551
|
+
|
552
|
+
end
|
553
|
+
|
554
|
+
#
|
555
|
+
# test the calculation of the base-10-logarithm function
|
556
|
+
#
|
557
|
+
def test_log10
|
558
|
+
check_log10_floated(10**2000, 30)
|
559
|
+
check_log10_floated(100, 30)
|
560
|
+
check_log10_floated(1, 30)
|
561
|
+
check_log10_floated(0.01, 30)
|
562
|
+
check_log10_floated(1e-10, 30)
|
563
|
+
check_log10_floated(1e-90, 30)
|
564
|
+
check_log10_floated(1e-300, 30)
|
565
|
+
check_log10_floated(LongDecimal(1, 2000), 30)
|
566
|
+
|
567
|
+
check_log10_exact(10**2000, 2000, 30)
|
568
|
+
check_log10_exact(10**0, 0, 30)
|
569
|
+
check_log10_exact(10**1, 1, 30)
|
570
|
+
check_log10_exact(10**10, 10, 30)
|
571
|
+
|
572
|
+
# random tests that have failed
|
573
|
+
check_log10_floated(LongDecimal("587.00000000000000000095700000000000000000000000000000000000000000000000000000000000000000000001206"), 21)
|
574
|
+
check_log10_floated(LongDecimal("543.0000002480000900000000000000000000000000000000000000000000000000000000000000000000847"), 2)
|
575
|
+
check_log10_floated(LongDecimal("180.0000000000000000003570000000000000000000000000000000000000000000000577000000000000000000000000000637"), 2)
|
576
|
+
check_log10_floated(LongDecimal("0.0000000000000000000000000000000000000000180000000063000000000000000000000000000000000025"), 74)
|
577
|
+
check_log10_floated(LongDecimal("0.0000000000000000000000000006200000000000000000000000000000000000000000000000007940000015"), 74)
|
578
|
+
check_log10_floated(LongDecimal("0.00000000000000000000000000000000000000000032900000000000000000000233000000000000000000000000000000254"), 10)
|
579
|
+
check_log10_floated(LongDecimal("0.00000000000000000000000233000000094800000000000000000000000000000000000000000000000000000000000000682"), 100)
|
580
|
+
check_log10_floated(LongDecimal("0.000000000000000000000000000000000000097000000041500000000000000000784"), 97)
|
581
|
+
check_log10_floated(LongDecimal("185.000025300000000000000006320000000000000000000000000000737"), 27)
|
582
|
+
check_log10_floated(LongDecimal("0.00000000000000000000000000000302000000000000000000000000000000000000000000000000000000060673"), 100)
|
583
|
+
check_log10_floated(LongDecimal("442.000000000000045300000000000000000000000000000000000000000000000000000000000000000000000721000000000752"), 97)
|
584
|
+
check_log10_floated(LongDecimal("0.001030927835051546391752577284408545010096715910298651428936221023301883588097777204212461151695109779555577162172"), 62)
|
585
|
+
|
586
|
+
end
|
587
|
+
|
588
|
+
#
|
589
|
+
# test the calculation of the base-10-logarithm function
|
590
|
+
#
|
591
|
+
def test_log2
|
592
|
+
check_log2_floated(10**2000, 30)
|
593
|
+
check_log2_floated(2**2000, 30)
|
594
|
+
check_log2_floated(100, 30)
|
595
|
+
check_log2_floated(1, 30)
|
596
|
+
check_log2_floated(0.01, 30)
|
597
|
+
check_log2_floated(1e-10, 30)
|
598
|
+
check_log2_floated(1e-90, 30)
|
599
|
+
check_log2_floated(1e-300, 30)
|
600
|
+
check_log2_floated(LongDecimal(1, 2000), 30)
|
601
|
+
|
602
|
+
check_log2_exact(2**2000, 2000, 30)
|
603
|
+
check_log2_exact(2**0, 0, 30)
|
604
|
+
check_log2_exact(2**1, 1, 30)
|
605
|
+
check_log2_exact(2**10, 10, 30)
|
606
|
+
|
607
|
+
# random tests that have failed
|
608
|
+
check_log2_floated(LongDecimal("341.00000739000000000000000000000000000000000000000000000000000000000000171"), 3)
|
609
|
+
check_log2_floated(LongDecimal("504.00000000000000000000000000000000000000000000000000000000000000000000000000000000000327400000000000828"), 1)
|
610
|
+
check_log2_floated(LongDecimal("0.0033222591362126245847176079734219269102990032888157967351353737817463383406363175903135730345286354858609181999523961456225622835123748782987926188031081"), 48)
|
611
|
+
check_log2_floated(LongDecimal("0.000802000000000000000000197000000000000000000000302"), 84)
|
612
|
+
check_log2_floated(LongDecimal("0.00000000000000000000000000000000000000000000000000000000000000000000000452000000000069480"), 3)
|
613
|
+
check_log2_floated(LongDecimal("0.0000000000000000000000000000000000000000000000000000930000000000000000000000000983000000000000300"), 61)
|
614
|
+
check_log2_floated(LongDecimal("0.000000000000000000000000000000000000000000000000000000000086000133000000000000000000000000947"), 106)
|
615
|
+
check_log2_floated(LongDecimal("0.00000000000000000000000000000276000000000000000000000000000000000008560000000000000000000000000000161"), 81)
|
616
|
+
|
617
|
+
end
|
618
|
+
|
619
|
+
#
|
620
|
+
# test the calculation of the base-x-logarithm of sqrt(x)
|
621
|
+
#
|
622
|
+
def test_log_2_10_of_sqrt
|
623
|
+
# n = 125
|
624
|
+
n = 30
|
625
|
+
m = 5
|
626
|
+
x2 = LongMath.sqrt(2, n)
|
627
|
+
x10 = LongMath.sqrt(10, n)
|
628
|
+
|
629
|
+
(2*m).times do |i|
|
630
|
+
check_log2_floated(x2, n+m-i)
|
631
|
+
check_log10_floated(x10, n+m-i)
|
632
|
+
end
|
633
|
+
|
634
|
+
y2 = check_log2_floated(x2, n)
|
635
|
+
assert((y2*2).one?, "xe=#{x2} ye=#{y2}")
|
636
|
+
y10 = check_log10_floated(x10, n)
|
637
|
+
assert((y10*2).one?, "xe=#{x10} ye=#{y10}")
|
638
|
+
|
639
|
+
end
|
640
|
+
|
641
|
+
end
|
642
|
+
|
643
|
+
RUNIT::CUI::TestRunner.run(TestLongDecimalExtra_class.suite)
|
644
|
+
|
645
|
+
# end of file testlongdecimal.rb
|