зеркало из https://github.com/github/ruby.git
* test/ruby/test_rational2.rb: updated.
* test/ruby/test_complex2.rb: added. * test/ruby/test_complexrational.rb: added. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19491 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
e7e5b731c2
Коммит
74cb0507ab
|
@ -1,3 +1,11 @@
|
|||
Tue Sep 23 21:31:16 2008 Tadayoshi Funaba <tadf@dotrb.org>
|
||||
|
||||
* test/ruby/test_rational2.rb: updated.
|
||||
|
||||
* test/ruby/test_complex2.rb: added.
|
||||
|
||||
* test/ruby/test_complexrational.rb: added.
|
||||
|
||||
Tue Sep 23 21:26:32 2008 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* string.c (rb_str_casecmp): make the ordering consistent with
|
||||
|
|
|
@ -0,0 +1,735 @@
|
|||
require 'test/unit'
|
||||
|
||||
class Complex_Test2 < Test::Unit::TestCase
|
||||
|
||||
def test_kumi
|
||||
return unless defined?(Rational)
|
||||
|
||||
assert_equal(Complex(1, 0), +Complex(1, 0))
|
||||
assert_equal(Complex(-1, 0), -Complex(1, 0))
|
||||
assert_equal(Complex(2, 0),
|
||||
Complex(1, 0) + Complex(1, 0))
|
||||
assert_equal(Complex(0, 0),
|
||||
Complex(1, 0) - Complex(1, 0))
|
||||
assert_equal(Complex(1, 0),
|
||||
Complex(1, 0) * Complex(1, 0))
|
||||
assert_equal(Complex(1, 0),
|
||||
Complex(1, 0) / Complex(1, 0))
|
||||
assert_equal(Complex(1073741790, 0),
|
||||
Complex(1, 0) + Complex(1073741789, 0))
|
||||
assert_equal(Complex(-1073741788, 0),
|
||||
Complex(1, 0) - Complex(1073741789, 0))
|
||||
assert_equal(Complex(1073741789, 0),
|
||||
Complex(1, 0) * Complex(1073741789, 0))
|
||||
assert_equal(Complex(Rational(1, 1073741789), 0),
|
||||
Complex(1, 0) / Complex(1073741789, 0))
|
||||
assert_equal(Complex(1073741828, 0),
|
||||
Complex(1, 0) + Complex(1073741827, 0))
|
||||
assert_equal(Complex(-1073741826, 0),
|
||||
Complex(1, 0) - Complex(1073741827, 0))
|
||||
assert_equal(Complex(1073741827, 0),
|
||||
Complex(1, 0) * Complex(1073741827, 0))
|
||||
assert_equal(Complex(Rational(1, 1073741827), 0),
|
||||
Complex(1, 0) / Complex(1073741827, 0))
|
||||
assert_equal(Complex(1073741790, 1073741789),
|
||||
Complex(1, 0) + Complex(1073741789, 1073741789))
|
||||
assert_equal(Complex(-1073741788, -1073741789),
|
||||
Complex(1, 0) - Complex(1073741789, 1073741789))
|
||||
assert_equal(Complex(1073741789, 1073741789),
|
||||
Complex(1, 0) * Complex(1073741789, 1073741789))
|
||||
assert_equal(Complex(Rational(1, 2147483578), Rational(-1, 2147483578)),
|
||||
Complex(1, 0) / Complex(1073741789, 1073741789))
|
||||
assert_equal(Complex(1073741790, 1073741827),
|
||||
Complex(1, 0) + Complex(1073741789, 1073741827))
|
||||
assert_equal(Complex(-1073741788, -1073741827),
|
||||
Complex(1, 0) - Complex(1073741789, 1073741827))
|
||||
assert_equal(Complex(1073741789, 1073741827),
|
||||
Complex(1, 0) * Complex(1073741789, 1073741827))
|
||||
assert_equal(Complex(Rational(1073741789, 2305842940494218450), Rational(-1073741827, 2305842940494218450)),
|
||||
Complex(1, 0) / Complex(1073741789, 1073741827))
|
||||
assert_equal(Complex(1073741828, 1073741827),
|
||||
Complex(1, 0) + Complex(1073741827, 1073741827))
|
||||
assert_equal(Complex(-1073741826, -1073741827),
|
||||
Complex(1, 0) - Complex(1073741827, 1073741827))
|
||||
assert_equal(Complex(1073741827, 1073741827),
|
||||
Complex(1, 0) * Complex(1073741827, 1073741827))
|
||||
assert_equal(Complex(Rational(1, 2147483654), Rational(-1, 2147483654)),
|
||||
Complex(1, 0) / Complex(1073741827, 1073741827))
|
||||
assert_equal(Complex(Rational(2147483616, 1073741827), Rational(1073741789, 1073741827)),
|
||||
Complex(1, 0) + Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)))
|
||||
assert_equal(Complex(Rational(38, 1073741827), Rational(-1073741789, 1073741827)),
|
||||
Complex(1, 0) - Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)))
|
||||
assert_equal(Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)),
|
||||
Complex(1, 0) * Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)))
|
||||
assert_equal(Complex(Rational(1073741827, 2147483578), Rational(-1073741827, 2147483578)),
|
||||
Complex(1, 0) / Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)))
|
||||
assert_equal(Complex(Rational(2147483616, 1073741789), Rational(1073741827, 1073741789)),
|
||||
Complex(1, 0) + Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(-38, 1073741789), Rational(-1073741827, 1073741789)),
|
||||
Complex(1, 0) - Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)),
|
||||
Complex(1, 0) * Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(1073741789, 2147483654), Rational(-1073741789, 2147483654)),
|
||||
Complex(1, 0) / Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(2147483616, 1073741827), Rational(1073741827, 1073741789)),
|
||||
Complex(1, 0) + Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(38, 1073741827), Rational(-1073741827, 1073741789)),
|
||||
Complex(1, 0) - Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)),
|
||||
Complex(1, 0) * Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(1329227869515035739611240300898290063, 2658455833113515253509575011810600482), Rational(-1329227963598474519442525600436190287, 2658455833113515253509575011810600482)),
|
||||
Complex(1, 0) / Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(1073741789, 0), +Complex(1073741789, 0))
|
||||
assert_equal(Complex(-1073741789, 0), -Complex(1073741789, 0))
|
||||
assert_equal(Complex(1073741790, 0),
|
||||
Complex(1073741789, 0) + Complex(1, 0))
|
||||
assert_equal(Complex(1073741788, 0),
|
||||
Complex(1073741789, 0) - Complex(1, 0))
|
||||
assert_equal(Complex(1073741789, 0),
|
||||
Complex(1073741789, 0) * Complex(1, 0))
|
||||
assert_equal(Complex(1073741789, 0),
|
||||
Complex(1073741789, 0) / Complex(1, 0))
|
||||
assert_equal(Complex(2147483578, 0),
|
||||
Complex(1073741789, 0) + Complex(1073741789, 0))
|
||||
assert_equal(Complex(0, 0),
|
||||
Complex(1073741789, 0) - Complex(1073741789, 0))
|
||||
assert_equal(Complex(1152921429444920521, 0),
|
||||
Complex(1073741789, 0) * Complex(1073741789, 0))
|
||||
assert_equal(Complex(1, 0),
|
||||
Complex(1073741789, 0) / Complex(1073741789, 0))
|
||||
assert_equal(Complex(2147483616, 0),
|
||||
Complex(1073741789, 0) + Complex(1073741827, 0))
|
||||
assert_equal(Complex(-38, 0),
|
||||
Complex(1073741789, 0) - Complex(1073741827, 0))
|
||||
assert_equal(Complex(1152921470247108503, 0),
|
||||
Complex(1073741789, 0) * Complex(1073741827, 0))
|
||||
assert_equal(Complex(Rational(1073741789, 1073741827), 0),
|
||||
Complex(1073741789, 0) / Complex(1073741827, 0))
|
||||
assert_equal(Complex(2147483578, 1073741789),
|
||||
Complex(1073741789, 0) + Complex(1073741789, 1073741789))
|
||||
assert_equal(Complex(0, -1073741789),
|
||||
Complex(1073741789, 0) - Complex(1073741789, 1073741789))
|
||||
assert_equal(Complex(1152921429444920521, 1152921429444920521),
|
||||
Complex(1073741789, 0) * Complex(1073741789, 1073741789))
|
||||
assert_equal(Complex(Rational(1, 2), Rational(-1, 2)),
|
||||
Complex(1073741789, 0) / Complex(1073741789, 1073741789))
|
||||
assert_equal(Complex(2147483578, 1073741827),
|
||||
Complex(1073741789, 0) + Complex(1073741789, 1073741827))
|
||||
assert_equal(Complex(0, -1073741827),
|
||||
Complex(1073741789, 0) - Complex(1073741789, 1073741827))
|
||||
assert_equal(Complex(1152921429444920521, 1152921470247108503),
|
||||
Complex(1073741789, 0) * Complex(1073741789, 1073741827))
|
||||
assert_equal(Complex(Rational(1152921429444920521, 2305842940494218450), Rational(-1152921470247108503, 2305842940494218450)),
|
||||
Complex(1073741789, 0) / Complex(1073741789, 1073741827))
|
||||
assert_equal(Complex(2147483616, 1073741827),
|
||||
Complex(1073741789, 0) + Complex(1073741827, 1073741827))
|
||||
assert_equal(Complex(-38, -1073741827),
|
||||
Complex(1073741789, 0) - Complex(1073741827, 1073741827))
|
||||
assert_equal(Complex(1152921470247108503, 1152921470247108503),
|
||||
Complex(1073741789, 0) * Complex(1073741827, 1073741827))
|
||||
assert_equal(Complex(Rational(1073741789, 2147483654), Rational(-1073741789, 2147483654)),
|
||||
Complex(1073741789, 0) / Complex(1073741827, 1073741827))
|
||||
assert_equal(Complex(Rational(1152921471320850292, 1073741827), Rational(1073741789, 1073741827)),
|
||||
Complex(1073741789, 0) + Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)))
|
||||
assert_equal(Complex(Rational(1152921469173366714, 1073741827), Rational(-1073741789, 1073741827)),
|
||||
Complex(1073741789, 0) - Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)))
|
||||
assert_equal(Complex(Rational(1152921429444920521, 1073741827), Rational(1152921429444920521, 1073741827)),
|
||||
Complex(1073741789, 0) * Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)))
|
||||
assert_equal(Complex(Rational(1073741827, 2), Rational(-1073741827, 2)),
|
||||
Complex(1073741789, 0) / Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)))
|
||||
assert_equal(Complex(Rational(1152921430518662348, 1073741789), Rational(1073741827, 1073741789)),
|
||||
Complex(1073741789, 0) + Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(1152921428371178694, 1073741789), Rational(-1073741827, 1073741789)),
|
||||
Complex(1073741789, 0) - Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(1073741827, 1073741827),
|
||||
Complex(1073741789, 0) * Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(1152921429444920521, 2147483654), Rational(-1152921429444920521, 2147483654)),
|
||||
Complex(1073741789, 0) / Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(1152921471320850292, 1073741827), Rational(1073741827, 1073741789)),
|
||||
Complex(1073741789, 0) + Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(1152921469173366714, 1073741827), Rational(-1073741827, 1073741789)),
|
||||
Complex(1073741789, 0) - Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(1152921429444920521, 1073741827), 1073741827),
|
||||
Complex(1073741789, 0) * Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(1427247510601733037449111325195428279286542707, 2658455833113515253509575011810600482), Rational(-1427247611623052908177132720890654139107803443, 2658455833113515253509575011810600482)),
|
||||
Complex(1073741789, 0) / Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(1073741827, 0), +Complex(1073741827, 0))
|
||||
assert_equal(Complex(-1073741827, 0), -Complex(1073741827, 0))
|
||||
assert_equal(Complex(1073741828, 0),
|
||||
Complex(1073741827, 0) + Complex(1, 0))
|
||||
assert_equal(Complex(1073741826, 0),
|
||||
Complex(1073741827, 0) - Complex(1, 0))
|
||||
assert_equal(Complex(1073741827, 0),
|
||||
Complex(1073741827, 0) * Complex(1, 0))
|
||||
assert_equal(Complex(1073741827, 0),
|
||||
Complex(1073741827, 0) / Complex(1, 0))
|
||||
assert_equal(Complex(2147483616, 0),
|
||||
Complex(1073741827, 0) + Complex(1073741789, 0))
|
||||
assert_equal(Complex(38, 0),
|
||||
Complex(1073741827, 0) - Complex(1073741789, 0))
|
||||
assert_equal(Complex(1152921470247108503, 0),
|
||||
Complex(1073741827, 0) * Complex(1073741789, 0))
|
||||
assert_equal(Complex(Rational(1073741827, 1073741789), 0),
|
||||
Complex(1073741827, 0) / Complex(1073741789, 0))
|
||||
assert_equal(Complex(2147483654, 0),
|
||||
Complex(1073741827, 0) + Complex(1073741827, 0))
|
||||
assert_equal(Complex(0, 0),
|
||||
Complex(1073741827, 0) - Complex(1073741827, 0))
|
||||
assert_equal(Complex(1152921511049297929, 0),
|
||||
Complex(1073741827, 0) * Complex(1073741827, 0))
|
||||
assert_equal(Complex(1, 0),
|
||||
Complex(1073741827, 0) / Complex(1073741827, 0))
|
||||
assert_equal(Complex(2147483616, 1073741789),
|
||||
Complex(1073741827, 0) + Complex(1073741789, 1073741789))
|
||||
assert_equal(Complex(38, -1073741789),
|
||||
Complex(1073741827, 0) - Complex(1073741789, 1073741789))
|
||||
assert_equal(Complex(1152921470247108503, 1152921470247108503),
|
||||
Complex(1073741827, 0) * Complex(1073741789, 1073741789))
|
||||
assert_equal(Complex(Rational(1073741827, 2147483578), Rational(-1073741827, 2147483578)),
|
||||
Complex(1073741827, 0) / Complex(1073741789, 1073741789))
|
||||
assert_equal(Complex(2147483616, 1073741827),
|
||||
Complex(1073741827, 0) + Complex(1073741789, 1073741827))
|
||||
assert_equal(Complex(38, -1073741827),
|
||||
Complex(1073741827, 0) - Complex(1073741789, 1073741827))
|
||||
assert_equal(Complex(1152921470247108503, 1152921511049297929),
|
||||
Complex(1073741827, 0) * Complex(1073741789, 1073741827))
|
||||
assert_equal(Complex(Rational(1152921470247108503, 2305842940494218450), Rational(-1152921511049297929, 2305842940494218450)),
|
||||
Complex(1073741827, 0) / Complex(1073741789, 1073741827))
|
||||
assert_equal(Complex(2147483654, 1073741827),
|
||||
Complex(1073741827, 0) + Complex(1073741827, 1073741827))
|
||||
assert_equal(Complex(0, -1073741827),
|
||||
Complex(1073741827, 0) - Complex(1073741827, 1073741827))
|
||||
assert_equal(Complex(1152921511049297929, 1152921511049297929),
|
||||
Complex(1073741827, 0) * Complex(1073741827, 1073741827))
|
||||
assert_equal(Complex(Rational(1, 2), Rational(-1, 2)),
|
||||
Complex(1073741827, 0) / Complex(1073741827, 1073741827))
|
||||
assert_equal(Complex(Rational(1152921512123039718, 1073741827), Rational(1073741789, 1073741827)),
|
||||
Complex(1073741827, 0) + Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)))
|
||||
assert_equal(Complex(Rational(1152921509975556140, 1073741827), Rational(-1073741789, 1073741827)),
|
||||
Complex(1073741827, 0) - Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)))
|
||||
assert_equal(Complex(1073741789, 1073741789),
|
||||
Complex(1073741827, 0) * Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)))
|
||||
assert_equal(Complex(Rational(1152921511049297929, 2147483578), Rational(-1152921511049297929, 2147483578)),
|
||||
Complex(1073741827, 0) / Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)))
|
||||
assert_equal(Complex(Rational(1152921471320850330, 1073741789), Rational(1073741827, 1073741789)),
|
||||
Complex(1073741827, 0) + Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(1152921469173366676, 1073741789), Rational(-1073741827, 1073741789)),
|
||||
Complex(1073741827, 0) - Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(1152921511049297929, 1073741789), Rational(1152921511049297929, 1073741789)),
|
||||
Complex(1073741827, 0) * Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(1073741789, 2), Rational(-1073741789, 2)),
|
||||
Complex(1073741827, 0) / Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(1152921512123039718, 1073741827), Rational(1073741827, 1073741789)),
|
||||
Complex(1073741827, 0) + Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(1152921509975556140, 1073741827), Rational(-1073741827, 1073741789)),
|
||||
Complex(1073741827, 0) - Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(1073741789, Rational(1152921511049297929, 1073741789)),
|
||||
Complex(1073741827, 0) * Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(1427247561112392079020469430422559713421565101, 2658455833113515253509575011810600482), Rational(-1427247662133715524919164459706626955683034349, 2658455833113515253509575011810600482)),
|
||||
Complex(1073741827, 0) / Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(1073741789, 1073741789), +Complex(1073741789, 1073741789))
|
||||
assert_equal(Complex(-1073741789, -1073741789), -Complex(1073741789, 1073741789))
|
||||
assert_equal(Complex(1073741790, 1073741789),
|
||||
Complex(1073741789, 1073741789) + Complex(1, 0))
|
||||
assert_equal(Complex(1073741788, 1073741789),
|
||||
Complex(1073741789, 1073741789) - Complex(1, 0))
|
||||
assert_equal(Complex(1073741789, 1073741789),
|
||||
Complex(1073741789, 1073741789) * Complex(1, 0))
|
||||
assert_equal(Complex(1073741789, 1073741789),
|
||||
Complex(1073741789, 1073741789) / Complex(1, 0))
|
||||
assert_equal(Complex(2147483578, 1073741789),
|
||||
Complex(1073741789, 1073741789) + Complex(1073741789, 0))
|
||||
assert_equal(Complex(0, 1073741789),
|
||||
Complex(1073741789, 1073741789) - Complex(1073741789, 0))
|
||||
assert_equal(Complex(1152921429444920521, 1152921429444920521),
|
||||
Complex(1073741789, 1073741789) * Complex(1073741789, 0))
|
||||
assert_equal(Complex(1, 1),
|
||||
Complex(1073741789, 1073741789) / Complex(1073741789, 0))
|
||||
assert_equal(Complex(2147483616, 1073741789),
|
||||
Complex(1073741789, 1073741789) + Complex(1073741827, 0))
|
||||
assert_equal(Complex(-38, 1073741789),
|
||||
Complex(1073741789, 1073741789) - Complex(1073741827, 0))
|
||||
assert_equal(Complex(1152921470247108503, 1152921470247108503),
|
||||
Complex(1073741789, 1073741789) * Complex(1073741827, 0))
|
||||
assert_equal(Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)),
|
||||
Complex(1073741789, 1073741789) / Complex(1073741827, 0))
|
||||
assert_equal(Complex(2147483578, 2147483578),
|
||||
Complex(1073741789, 1073741789) + Complex(1073741789, 1073741789))
|
||||
assert_equal(Complex(0, 0),
|
||||
Complex(1073741789, 1073741789) - Complex(1073741789, 1073741789))
|
||||
assert_equal(Complex(0, 2305842858889841042),
|
||||
Complex(1073741789, 1073741789) * Complex(1073741789, 1073741789))
|
||||
assert_equal(Complex(1, 0),
|
||||
Complex(1073741789, 1073741789) / Complex(1073741789, 1073741789))
|
||||
assert_equal(Complex(2147483578, 2147483616),
|
||||
Complex(1073741789, 1073741789) + Complex(1073741789, 1073741827))
|
||||
assert_equal(Complex(0, -38),
|
||||
Complex(1073741789, 1073741789) - Complex(1073741789, 1073741827))
|
||||
assert_equal(Complex(-40802187982, 2305842899692029024),
|
||||
Complex(1073741789, 1073741789) * Complex(1073741789, 1073741827))
|
||||
assert_equal(Complex(Rational(1152921449846014512, 1152921470247109225), Rational(-20401093991, 1152921470247109225)),
|
||||
Complex(1073741789, 1073741789) / Complex(1073741789, 1073741827))
|
||||
assert_equal(Complex(2147483616, 2147483616),
|
||||
Complex(1073741789, 1073741789) + Complex(1073741827, 1073741827))
|
||||
assert_equal(Complex(-38, -38),
|
||||
Complex(1073741789, 1073741789) - Complex(1073741827, 1073741827))
|
||||
assert_equal(Complex(0, 2305842940494217006),
|
||||
Complex(1073741789, 1073741789) * Complex(1073741827, 1073741827))
|
||||
assert_equal(Complex(Rational(1073741789, 1073741827), 0),
|
||||
Complex(1073741789, 1073741789) / Complex(1073741827, 1073741827))
|
||||
assert_equal(Complex(Rational(1152921471320850292, 1073741827), Rational(1152921471320850292, 1073741827)),
|
||||
Complex(1073741789, 1073741789) + Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)))
|
||||
assert_equal(Complex(Rational(1152921469173366714, 1073741827), Rational(1152921469173366714, 1073741827)),
|
||||
Complex(1073741789, 1073741789) - Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)))
|
||||
assert_equal(Complex(0, Rational(2305842858889841042, 1073741827)),
|
||||
Complex(1073741789, 1073741789) * Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)))
|
||||
assert_equal(Complex(1073741827, 0),
|
||||
Complex(1073741789, 1073741789) / Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)))
|
||||
assert_equal(Complex(Rational(1152921430518662348, 1073741789), Rational(1152921430518662348, 1073741789)),
|
||||
Complex(1073741789, 1073741789) + Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(1152921428371178694, 1073741789), Rational(1152921428371178694, 1073741789)),
|
||||
Complex(1073741789, 1073741789) - Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(0, 2147483654),
|
||||
Complex(1073741789, 1073741789) * Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(1152921429444920521, 1073741827), 0),
|
||||
Complex(1073741789, 1073741789) / Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(1152921471320850292, 1073741827), Rational(1152921430518662348, 1073741789)),
|
||||
Complex(1073741789, 1073741789) + Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(1152921469173366714, 1073741827), Rational(1152921428371178694, 1073741789)),
|
||||
Complex(1073741789, 1073741789) - Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(-81604377408, 1073741827), Rational(2305842940494218450, 1073741827)),
|
||||
Complex(1073741789, 1073741789) * Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(1427247561112392972813122023043041209197173075, 1329227916556757626754787505905300241), Rational(-50510659935364010697847612929910630368, 1329227916556757626754787505905300241)),
|
||||
Complex(1073741789, 1073741789) / Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(1073741789, 1073741827), +Complex(1073741789, 1073741827))
|
||||
assert_equal(Complex(-1073741789, -1073741827), -Complex(1073741789, 1073741827))
|
||||
assert_equal(Complex(1073741790, 1073741827),
|
||||
Complex(1073741789, 1073741827) + Complex(1, 0))
|
||||
assert_equal(Complex(1073741788, 1073741827),
|
||||
Complex(1073741789, 1073741827) - Complex(1, 0))
|
||||
assert_equal(Complex(1073741789, 1073741827),
|
||||
Complex(1073741789, 1073741827) * Complex(1, 0))
|
||||
assert_equal(Complex(1073741789, 1073741827),
|
||||
Complex(1073741789, 1073741827) / Complex(1, 0))
|
||||
assert_equal(Complex(2147483578, 1073741827),
|
||||
Complex(1073741789, 1073741827) + Complex(1073741789, 0))
|
||||
assert_equal(Complex(0, 1073741827),
|
||||
Complex(1073741789, 1073741827) - Complex(1073741789, 0))
|
||||
assert_equal(Complex(1152921429444920521, 1152921470247108503),
|
||||
Complex(1073741789, 1073741827) * Complex(1073741789, 0))
|
||||
assert_equal(Complex(1, Rational(1073741827, 1073741789)),
|
||||
Complex(1073741789, 1073741827) / Complex(1073741789, 0))
|
||||
assert_equal(Complex(2147483616, 1073741827),
|
||||
Complex(1073741789, 1073741827) + Complex(1073741827, 0))
|
||||
assert_equal(Complex(-38, 1073741827),
|
||||
Complex(1073741789, 1073741827) - Complex(1073741827, 0))
|
||||
assert_equal(Complex(1152921470247108503, 1152921511049297929),
|
||||
Complex(1073741789, 1073741827) * Complex(1073741827, 0))
|
||||
assert_equal(Complex(Rational(1073741789, 1073741827), 1),
|
||||
Complex(1073741789, 1073741827) / Complex(1073741827, 0))
|
||||
assert_equal(Complex(2147483578, 2147483616),
|
||||
Complex(1073741789, 1073741827) + Complex(1073741789, 1073741789))
|
||||
assert_equal(Complex(0, 38),
|
||||
Complex(1073741789, 1073741827) - Complex(1073741789, 1073741789))
|
||||
assert_equal(Complex(-40802187982, 2305842899692029024),
|
||||
Complex(1073741789, 1073741827) * Complex(1073741789, 1073741789))
|
||||
assert_equal(Complex(Rational(1073741808, 1073741789), Rational(19, 1073741789)),
|
||||
Complex(1073741789, 1073741827) / Complex(1073741789, 1073741789))
|
||||
assert_equal(Complex(2147483578, 2147483654),
|
||||
Complex(1073741789, 1073741827) + Complex(1073741789, 1073741827))
|
||||
assert_equal(Complex(0, 0),
|
||||
Complex(1073741789, 1073741827) - Complex(1073741789, 1073741827))
|
||||
assert_equal(Complex(-81604377408, 2305842940494217006),
|
||||
Complex(1073741789, 1073741827) * Complex(1073741789, 1073741827))
|
||||
assert_equal(Complex(1, 0),
|
||||
Complex(1073741789, 1073741827) / Complex(1073741789, 1073741827))
|
||||
assert_equal(Complex(2147483616, 2147483654),
|
||||
Complex(1073741789, 1073741827) + Complex(1073741827, 1073741827))
|
||||
assert_equal(Complex(-38, 0),
|
||||
Complex(1073741789, 1073741827) - Complex(1073741827, 1073741827))
|
||||
assert_equal(Complex(-40802189426, 2305842981296406432),
|
||||
Complex(1073741789, 1073741827) * Complex(1073741827, 1073741827))
|
||||
assert_equal(Complex(Rational(1073741808, 1073741827), Rational(19, 1073741827)),
|
||||
Complex(1073741789, 1073741827) / Complex(1073741827, 1073741827))
|
||||
assert_equal(Complex(Rational(1152921471320850292, 1073741827), Rational(1152921512123039718, 1073741827)),
|
||||
Complex(1073741789, 1073741827) + Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)))
|
||||
assert_equal(Complex(Rational(1152921469173366714, 1073741827), Rational(1152921509975556140, 1073741827)),
|
||||
Complex(1073741789, 1073741827) - Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)))
|
||||
assert_equal(Complex(Rational(-40802187982, 1073741827), Rational(2305842899692029024, 1073741827)),
|
||||
Complex(1073741789, 1073741827) * Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)))
|
||||
assert_equal(Complex(Rational(1152921490648203216, 1073741789), Rational(20401094713, 1073741789)),
|
||||
Complex(1073741789, 1073741827) / Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)))
|
||||
assert_equal(Complex(Rational(1152921430518662348, 1073741789), Rational(1152921471320850330, 1073741789)),
|
||||
Complex(1073741789, 1073741827) + Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(1152921428371178694, 1073741789), Rational(1152921469173366676, 1073741789)),
|
||||
Complex(1073741789, 1073741827) - Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(-40802189426, 1073741789), Rational(2305842981296406432, 1073741789)),
|
||||
Complex(1073741789, 1073741827) * Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(1152921449846014512, 1073741827), Rational(20401093991, 1073741827)),
|
||||
Complex(1073741789, 1073741827) / Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(1152921471320850292, 1073741827), Rational(1152921471320850330, 1073741789)),
|
||||
Complex(1073741789, 1073741827) + Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(1152921469173366714, 1073741827), Rational(1152921469173366676, 1073741789)),
|
||||
Complex(1073741789, 1073741827) - Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(-131433047608170424214, 1152921470247108503), 2147483616),
|
||||
Complex(1073741789, 1073741827) * Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(1427247586367724281184137892451027617484788528, 1329227916556757626754787505905300241), Rational(-25255330414578331645234047212843119171, 1329227916556757626754787505905300241)),
|
||||
Complex(1073741789, 1073741827) / Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(1073741827, 1073741827), +Complex(1073741827, 1073741827))
|
||||
assert_equal(Complex(-1073741827, -1073741827), -Complex(1073741827, 1073741827))
|
||||
assert_equal(Complex(1073741828, 1073741827),
|
||||
Complex(1073741827, 1073741827) + Complex(1, 0))
|
||||
assert_equal(Complex(1073741826, 1073741827),
|
||||
Complex(1073741827, 1073741827) - Complex(1, 0))
|
||||
assert_equal(Complex(1073741827, 1073741827),
|
||||
Complex(1073741827, 1073741827) * Complex(1, 0))
|
||||
assert_equal(Complex(1073741827, 1073741827),
|
||||
Complex(1073741827, 1073741827) / Complex(1, 0))
|
||||
assert_equal(Complex(2147483616, 1073741827),
|
||||
Complex(1073741827, 1073741827) + Complex(1073741789, 0))
|
||||
assert_equal(Complex(38, 1073741827),
|
||||
Complex(1073741827, 1073741827) - Complex(1073741789, 0))
|
||||
assert_equal(Complex(1152921470247108503, 1152921470247108503),
|
||||
Complex(1073741827, 1073741827) * Complex(1073741789, 0))
|
||||
assert_equal(Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)),
|
||||
Complex(1073741827, 1073741827) / Complex(1073741789, 0))
|
||||
assert_equal(Complex(2147483654, 1073741827),
|
||||
Complex(1073741827, 1073741827) + Complex(1073741827, 0))
|
||||
assert_equal(Complex(0, 1073741827),
|
||||
Complex(1073741827, 1073741827) - Complex(1073741827, 0))
|
||||
assert_equal(Complex(1152921511049297929, 1152921511049297929),
|
||||
Complex(1073741827, 1073741827) * Complex(1073741827, 0))
|
||||
assert_equal(Complex(1, 1),
|
||||
Complex(1073741827, 1073741827) / Complex(1073741827, 0))
|
||||
assert_equal(Complex(2147483616, 2147483616),
|
||||
Complex(1073741827, 1073741827) + Complex(1073741789, 1073741789))
|
||||
assert_equal(Complex(38, 38),
|
||||
Complex(1073741827, 1073741827) - Complex(1073741789, 1073741789))
|
||||
assert_equal(Complex(0, 2305842940494217006),
|
||||
Complex(1073741827, 1073741827) * Complex(1073741789, 1073741789))
|
||||
assert_equal(Complex(Rational(1073741827, 1073741789), 0),
|
||||
Complex(1073741827, 1073741827) / Complex(1073741789, 1073741789))
|
||||
assert_equal(Complex(2147483616, 2147483654),
|
||||
Complex(1073741827, 1073741827) + Complex(1073741789, 1073741827))
|
||||
assert_equal(Complex(38, 0),
|
||||
Complex(1073741827, 1073741827) - Complex(1073741789, 1073741827))
|
||||
assert_equal(Complex(-40802189426, 2305842981296406432),
|
||||
Complex(1073741827, 1073741827) * Complex(1073741789, 1073741827))
|
||||
assert_equal(Complex(Rational(1152921490648203216, 1152921470247109225), Rational(-20401094713, 1152921470247109225)),
|
||||
Complex(1073741827, 1073741827) / Complex(1073741789, 1073741827))
|
||||
assert_equal(Complex(2147483654, 2147483654),
|
||||
Complex(1073741827, 1073741827) + Complex(1073741827, 1073741827))
|
||||
assert_equal(Complex(0, 0),
|
||||
Complex(1073741827, 1073741827) - Complex(1073741827, 1073741827))
|
||||
assert_equal(Complex(0, 2305843022098595858),
|
||||
Complex(1073741827, 1073741827) * Complex(1073741827, 1073741827))
|
||||
assert_equal(Complex(1, 0),
|
||||
Complex(1073741827, 1073741827) / Complex(1073741827, 1073741827))
|
||||
assert_equal(Complex(Rational(1152921512123039718, 1073741827), Rational(1152921512123039718, 1073741827)),
|
||||
Complex(1073741827, 1073741827) + Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)))
|
||||
assert_equal(Complex(Rational(1152921509975556140, 1073741827), Rational(1152921509975556140, 1073741827)),
|
||||
Complex(1073741827, 1073741827) - Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)))
|
||||
assert_equal(Complex(0, 2147483578),
|
||||
Complex(1073741827, 1073741827) * Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)))
|
||||
assert_equal(Complex(Rational(1152921511049297929, 1073741789), 0),
|
||||
Complex(1073741827, 1073741827) / Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)))
|
||||
assert_equal(Complex(Rational(1152921471320850330, 1073741789), Rational(1152921471320850330, 1073741789)),
|
||||
Complex(1073741827, 1073741827) + Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(1152921469173366676, 1073741789), Rational(1152921469173366676, 1073741789)),
|
||||
Complex(1073741827, 1073741827) - Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(0, Rational(2305843022098595858, 1073741789)),
|
||||
Complex(1073741827, 1073741827) * Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(1073741789, 0),
|
||||
Complex(1073741827, 1073741827) / Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(1152921512123039718, 1073741827), Rational(1152921471320850330, 1073741789)),
|
||||
Complex(1073741827, 1073741827) + Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(1152921509975556140, 1073741827), Rational(1152921469173366676, 1073741789)),
|
||||
Complex(1073741827, 1073741827) - Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(-81604377408, 1073741789), Rational(2305842940494218450, 1073741789)),
|
||||
Complex(1073741827, 1073741827) * Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(1427247611623053801969816945064593334552299725, 1329227916556757626754787505905300241), Rational(-50510661722949347514642033621130734624, 1329227916556757626754787505905300241)),
|
||||
Complex(1073741827, 1073741827) / Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)), +Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)))
|
||||
assert_equal(Complex(Rational(-1073741789, 1073741827), Rational(-1073741789, 1073741827)), -Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)))
|
||||
assert_equal(Complex(Rational(2147483616, 1073741827), Rational(1073741789, 1073741827)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) + Complex(1, 0))
|
||||
assert_equal(Complex(Rational(-38, 1073741827), Rational(1073741789, 1073741827)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) - Complex(1, 0))
|
||||
assert_equal(Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) * Complex(1, 0))
|
||||
assert_equal(Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) / Complex(1, 0))
|
||||
assert_equal(Complex(Rational(1152921471320850292, 1073741827), Rational(1073741789, 1073741827)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) + Complex(1073741789, 0))
|
||||
assert_equal(Complex(Rational(-1152921469173366714, 1073741827), Rational(1073741789, 1073741827)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) - Complex(1073741789, 0))
|
||||
assert_equal(Complex(Rational(1152921429444920521, 1073741827), Rational(1152921429444920521, 1073741827)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) * Complex(1073741789, 0))
|
||||
assert_equal(Complex(Rational(1, 1073741827), Rational(1, 1073741827)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) / Complex(1073741789, 0))
|
||||
assert_equal(Complex(Rational(1152921512123039718, 1073741827), Rational(1073741789, 1073741827)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) + Complex(1073741827, 0))
|
||||
assert_equal(Complex(Rational(-1152921509975556140, 1073741827), Rational(1073741789, 1073741827)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) - Complex(1073741827, 0))
|
||||
assert_equal(Complex(1073741789, 1073741789),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) * Complex(1073741827, 0))
|
||||
assert_equal(Complex(Rational(1073741789, 1152921511049297929), Rational(1073741789, 1152921511049297929)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) / Complex(1073741827, 0))
|
||||
assert_equal(Complex(Rational(1152921471320850292, 1073741827), Rational(1152921471320850292, 1073741827)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) + Complex(1073741789, 1073741789))
|
||||
assert_equal(Complex(Rational(-1152921469173366714, 1073741827), Rational(-1152921469173366714, 1073741827)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) - Complex(1073741789, 1073741789))
|
||||
assert_equal(Complex(0, Rational(2305842858889841042, 1073741827)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) * Complex(1073741789, 1073741789))
|
||||
assert_equal(Complex(Rational(1, 1073741827), 0),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) / Complex(1073741789, 1073741789))
|
||||
assert_equal(Complex(Rational(1152921471320850292, 1073741827), Rational(1152921512123039718, 1073741827)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) + Complex(1073741789, 1073741827))
|
||||
assert_equal(Complex(Rational(-1152921469173366714, 1073741827), Rational(-1152921509975556140, 1073741827)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) - Complex(1073741789, 1073741827))
|
||||
assert_equal(Complex(Rational(-40802187982, 1073741827), Rational(2305842899692029024, 1073741827)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) * Complex(1073741789, 1073741827))
|
||||
assert_equal(Complex(Rational(1152921449846014512, 1237940005850657200720054075), Rational(-20401093991, 1237940005850657200720054075)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) / Complex(1073741789, 1073741827))
|
||||
assert_equal(Complex(Rational(1152921512123039718, 1073741827), Rational(1152921512123039718, 1073741827)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) + Complex(1073741827, 1073741827))
|
||||
assert_equal(Complex(Rational(-1152921509975556140, 1073741827), Rational(-1152921509975556140, 1073741827)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) - Complex(1073741827, 1073741827))
|
||||
assert_equal(Complex(0, 2147483578),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) * Complex(1073741827, 1073741827))
|
||||
assert_equal(Complex(Rational(1073741789, 1152921511049297929), 0),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) / Complex(1073741827, 1073741827))
|
||||
assert_equal(Complex(Rational(2147483578, 1073741827), Rational(2147483578, 1073741827)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) + Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)))
|
||||
assert_equal(Complex(0, 0),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) - Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)))
|
||||
assert_equal(Complex(0, Rational(2305842858889841042, 1152921511049297929)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) * Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)))
|
||||
assert_equal(Complex(1, 0),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) / Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)))
|
||||
assert_equal(Complex(Rational(2305842940494218450, 1152921470247108503), Rational(2305842940494218450, 1152921470247108503)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) + Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(-81604377408, 1152921470247108503), Rational(-81604377408, 1152921470247108503)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) - Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(0, 2),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) * Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(1152921429444920521, 1152921511049297929), 0),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) / Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(2147483578, 1073741827), Rational(2305842940494218450, 1152921470247108503)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) + Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(0, Rational(-81604377408, 1152921470247108503)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) - Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(-81604377408, 1152921511049297929), Rational(2305842940494218450, 1152921511049297929)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) * Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(1329227869515036572020512360130906225, 1329227916556757626754787505905300241), Rational(-47041717725097069072123994784, 1329227916556757626754787505905300241)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)) / Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)), +Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(-1073741827, 1073741789), Rational(-1073741827, 1073741789)), -Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(2147483616, 1073741789), Rational(1073741827, 1073741789)),
|
||||
Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) + Complex(1, 0))
|
||||
assert_equal(Complex(Rational(38, 1073741789), Rational(1073741827, 1073741789)),
|
||||
Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) - Complex(1, 0))
|
||||
assert_equal(Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)),
|
||||
Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) * Complex(1, 0))
|
||||
assert_equal(Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)),
|
||||
Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) / Complex(1, 0))
|
||||
assert_equal(Complex(Rational(1152921430518662348, 1073741789), Rational(1073741827, 1073741789)),
|
||||
Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) + Complex(1073741789, 0))
|
||||
assert_equal(Complex(Rational(-1152921428371178694, 1073741789), Rational(1073741827, 1073741789)),
|
||||
Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) - Complex(1073741789, 0))
|
||||
assert_equal(Complex(1073741827, 1073741827),
|
||||
Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) * Complex(1073741789, 0))
|
||||
assert_equal(Complex(Rational(1073741827, 1152921429444920521), Rational(1073741827, 1152921429444920521)),
|
||||
Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) / Complex(1073741789, 0))
|
||||
assert_equal(Complex(Rational(1152921471320850330, 1073741789), Rational(1073741827, 1073741789)),
|
||||
Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) + Complex(1073741827, 0))
|
||||
assert_equal(Complex(Rational(-1152921469173366676, 1073741789), Rational(1073741827, 1073741789)),
|
||||
Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) - Complex(1073741827, 0))
|
||||
assert_equal(Complex(Rational(1152921511049297929, 1073741789), Rational(1152921511049297929, 1073741789)),
|
||||
Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) * Complex(1073741827, 0))
|
||||
assert_equal(Complex(Rational(1, 1073741789), Rational(1, 1073741789)),
|
||||
Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) / Complex(1073741827, 0))
|
||||
assert_equal(Complex(Rational(1152921430518662348, 1073741789), Rational(1152921430518662348, 1073741789)),
|
||||
Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) + Complex(1073741789, 1073741789))
|
||||
assert_equal(Complex(Rational(-1152921428371178694, 1073741789), Rational(-1152921428371178694, 1073741789)),
|
||||
Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) - Complex(1073741789, 1073741789))
|
||||
assert_equal(Complex(0, 2147483654),
|
||||
Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) * Complex(1073741789, 1073741789))
|
||||
assert_equal(Complex(Rational(1073741827, 1152921429444920521), 0),
|
||||
Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) / Complex(1073741789, 1073741789))
|
||||
assert_equal(Complex(Rational(1152921430518662348, 1073741789), Rational(1152921471320850330, 1073741789)),
|
||||
Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) + Complex(1073741789, 1073741827))
|
||||
assert_equal(Complex(Rational(-1152921428371178694, 1073741789), Rational(-1152921469173366676, 1073741789)),
|
||||
Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) - Complex(1073741789, 1073741827))
|
||||
assert_equal(Complex(Rational(-40802189426, 1073741789), Rational(2305842981296406432, 1073741789)),
|
||||
Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) * Complex(1073741789, 1073741827))
|
||||
assert_equal(Complex(Rational(1152921490648203216, 1237939962039641331329903525), Rational(-20401094713, 1237939962039641331329903525)),
|
||||
Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) / Complex(1073741789, 1073741827))
|
||||
assert_equal(Complex(Rational(1152921471320850330, 1073741789), Rational(1152921471320850330, 1073741789)),
|
||||
Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) + Complex(1073741827, 1073741827))
|
||||
assert_equal(Complex(Rational(-1152921469173366676, 1073741789), Rational(-1152921469173366676, 1073741789)),
|
||||
Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) - Complex(1073741827, 1073741827))
|
||||
assert_equal(Complex(0, Rational(2305843022098595858, 1073741789)),
|
||||
Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) * Complex(1073741827, 1073741827))
|
||||
assert_equal(Complex(Rational(1, 1073741789), 0),
|
||||
Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) / Complex(1073741827, 1073741827))
|
||||
assert_equal(Complex(Rational(2305842940494218450, 1152921470247108503), Rational(2305842940494218450, 1152921470247108503)),
|
||||
Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) + Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)))
|
||||
assert_equal(Complex(Rational(81604377408, 1152921470247108503), Rational(81604377408, 1152921470247108503)),
|
||||
Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) - Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)))
|
||||
assert_equal(Complex(0, 2),
|
||||
Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) * Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)))
|
||||
assert_equal(Complex(Rational(1152921511049297929, 1152921429444920521), 0),
|
||||
Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) / Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)))
|
||||
assert_equal(Complex(Rational(2147483654, 1073741789), Rational(2147483654, 1073741789)),
|
||||
Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) + Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(0, 0),
|
||||
Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) - Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(0, Rational(2305843022098595858, 1152921429444920521)),
|
||||
Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) * Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(1, 0),
|
||||
Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) / Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(2305842940494218450, 1152921470247108503), Rational(2147483654, 1073741789)),
|
||||
Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) + Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(81604377408, 1152921470247108503), 0),
|
||||
Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) - Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(-81604377408, 1152921429444920521), Rational(2305842940494218450, 1152921429444920521)),
|
||||
Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) * Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(1329227963598475351851856578029295025, 1329227916556757626754787505905300241), Rational(-47041721054734275145774394016, 1329227916556757626754787505905300241)),
|
||||
Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)) / Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)), +Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(-1073741789, 1073741827), Rational(-1073741827, 1073741789)), -Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(2147483616, 1073741827), Rational(1073741827, 1073741789)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) + Complex(1, 0))
|
||||
assert_equal(Complex(Rational(-38, 1073741827), Rational(1073741827, 1073741789)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) - Complex(1, 0))
|
||||
assert_equal(Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) * Complex(1, 0))
|
||||
assert_equal(Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) / Complex(1, 0))
|
||||
assert_equal(Complex(Rational(1152921471320850292, 1073741827), Rational(1073741827, 1073741789)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) + Complex(1073741789, 0))
|
||||
assert_equal(Complex(Rational(-1152921469173366714, 1073741827), Rational(1073741827, 1073741789)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) - Complex(1073741789, 0))
|
||||
assert_equal(Complex(Rational(1152921429444920521, 1073741827), 1073741827),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) * Complex(1073741789, 0))
|
||||
assert_equal(Complex(Rational(1, 1073741827), Rational(1073741827, 1152921429444920521)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) / Complex(1073741789, 0))
|
||||
assert_equal(Complex(Rational(1152921512123039718, 1073741827), Rational(1073741827, 1073741789)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) + Complex(1073741827, 0))
|
||||
assert_equal(Complex(Rational(-1152921509975556140, 1073741827), Rational(1073741827, 1073741789)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) - Complex(1073741827, 0))
|
||||
assert_equal(Complex(1073741789, Rational(1152921511049297929, 1073741789)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) * Complex(1073741827, 0))
|
||||
assert_equal(Complex(Rational(1073741789, 1152921511049297929), Rational(1, 1073741789)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) / Complex(1073741827, 0))
|
||||
assert_equal(Complex(Rational(1152921471320850292, 1073741827), Rational(1152921430518662348, 1073741789)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) + Complex(1073741789, 1073741789))
|
||||
assert_equal(Complex(Rational(-1152921469173366714, 1073741827), Rational(-1152921428371178694, 1073741789)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) - Complex(1073741789, 1073741789))
|
||||
assert_equal(Complex(Rational(-81604377408, 1073741827), Rational(2305842940494218450, 1073741827)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) * Complex(1073741789, 1073741789))
|
||||
assert_equal(Complex(Rational(1152921470247109225, 1237939962039640556088331867), Rational(40802188704, 1237939962039640556088331867)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) / Complex(1073741789, 1073741789))
|
||||
assert_equal(Complex(Rational(1152921471320850292, 1073741827), Rational(1152921471320850330, 1073741789)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) + Complex(1073741789, 1073741827))
|
||||
assert_equal(Complex(Rational(-1152921469173366714, 1073741827), Rational(-1152921469173366676, 1073741789)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) - Complex(1073741789, 1073741827))
|
||||
assert_equal(Complex(Rational(-131433047608170424214, 1152921470247108503), 2147483616),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) * Complex(1073741789, 1073741827))
|
||||
assert_equal(Complex(Rational(1237939983945150041266564176, 1329227916556755129526882950667240175), Rational(19, 1152921470247109225)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) / Complex(1073741789, 1073741827))
|
||||
assert_equal(Complex(Rational(1152921512123039718, 1073741827), Rational(1152921471320850330, 1073741789)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) + Complex(1073741827, 1073741827))
|
||||
assert_equal(Complex(Rational(-1152921509975556140, 1073741827), Rational(-1152921469173366676, 1073741789)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) - Complex(1073741827, 1073741827))
|
||||
assert_equal(Complex(Rational(-81604377408, 1073741789), Rational(2305842940494218450, 1073741789)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) * Complex(1073741827, 1073741827))
|
||||
assert_equal(Complex(Rational(1152921470247109225, 1237940005850656425478454981), Rational(40802188704, 1237940005850656425478454981)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) / Complex(1073741827, 1073741827))
|
||||
assert_equal(Complex(Rational(2147483578, 1073741827), Rational(2305842940494218450, 1152921470247108503)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) + Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)))
|
||||
assert_equal(Complex(0, Rational(81604377408, 1152921470247108503)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) - Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)))
|
||||
assert_equal(Complex(Rational(-81604377408, 1152921511049297929), Rational(2305842940494218450, 1152921511049297929)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) * Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)))
|
||||
assert_equal(Complex(Rational(1152921470247109225, 1152921429444920521), Rational(40802188704, 1152921429444920521)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) / Complex(Rational(1073741789, 1073741827), Rational(1073741789, 1073741827)))
|
||||
assert_equal(Complex(Rational(2305842940494218450, 1152921470247108503), Rational(2147483654, 1073741789)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) + Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(-81604377408, 1152921470247108503), 0),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) - Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(-81604377408, 1152921429444920521), Rational(2305842940494218450, 1152921429444920521)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) * Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(1152921470247109225, 1152921511049297929), Rational(40802188704, 1152921511049297929)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) / Complex(Rational(1073741827, 1073741789), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(2147483578, 1073741827), Rational(2147483654, 1073741789)),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) + Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(0, 0),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) - Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(Rational(-188166877559662688435796777600, 1329227916556754297117581432254901009), 2),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) * Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)))
|
||||
assert_equal(Complex(1, 0),
|
||||
Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)) / Complex(Rational(1073741789, 1073741827), Rational(1073741827, 1073741789)))
|
||||
end
|
||||
|
||||
def test_kumi2
|
||||
assert_equal('0.0+0.0i', (+Complex(+0.0, +0.0)).to_s)
|
||||
assert_equal('-0.0-0.0i', (-Complex(+0.0, +0.0)).to_s)
|
||||
assert_equal('0.0+0.0i', (Complex(+0.0, +0.0) + Complex(+0.0, +0.0)).to_s)
|
||||
assert_equal('0.0+0.0i', (Complex(+0.0, +0.0) - Complex(+0.0, +0.0)).to_s)
|
||||
assert_equal('0.0+0.0i', (Complex(+0.0, +0.0) * Complex(+0.0, +0.0)).to_s)
|
||||
assert_equal('0.0+0.0i', (Complex(+0.0, +0.0) + Complex(-0.0, +0.0)).to_s)
|
||||
assert_equal('0.0+0.0i', (Complex(+0.0, +0.0) - Complex(-0.0, +0.0)).to_s)
|
||||
assert_equal('-0.0+0.0i', (Complex(+0.0, +0.0) * Complex(-0.0, +0.0)).to_s)
|
||||
assert_equal('0.0+0.0i', (Complex(+0.0, +0.0) + Complex(+0.0, -0.0)).to_s)
|
||||
assert_equal('0.0+0.0i', (Complex(+0.0, +0.0) - Complex(+0.0, -0.0)).to_s)
|
||||
assert_equal('0.0+0.0i', (Complex(+0.0, +0.0) * Complex(+0.0, -0.0)).to_s)
|
||||
assert_equal('0.0+0.0i', (Complex(+0.0, +0.0) + Complex(-0.0, -0.0)).to_s)
|
||||
assert_equal('0.0+0.0i', (Complex(+0.0, +0.0) - Complex(-0.0, -0.0)).to_s)
|
||||
assert_equal('0.0-0.0i', (Complex(+0.0, +0.0) * Complex(-0.0, -0.0)).to_s)
|
||||
assert_equal('-0.0+0.0i', (+Complex(-0.0, +0.0)).to_s)
|
||||
assert_equal('0.0-0.0i', (-Complex(-0.0, +0.0)).to_s)
|
||||
assert_equal('0.0+0.0i', (Complex(-0.0, +0.0) + Complex(+0.0, +0.0)).to_s)
|
||||
assert_equal('-0.0+0.0i', (Complex(-0.0, +0.0) - Complex(+0.0, +0.0)).to_s)
|
||||
assert_equal('-0.0+0.0i', (Complex(-0.0, +0.0) * Complex(+0.0, +0.0)).to_s)
|
||||
assert_equal('-0.0+0.0i', (Complex(-0.0, +0.0) + Complex(-0.0, +0.0)).to_s)
|
||||
assert_equal('0.0+0.0i', (Complex(-0.0, +0.0) - Complex(-0.0, +0.0)).to_s)
|
||||
assert_equal('0.0-0.0i', (Complex(-0.0, +0.0) * Complex(-0.0, +0.0)).to_s)
|
||||
assert_equal('0.0+0.0i', (Complex(-0.0, +0.0) + Complex(+0.0, -0.0)).to_s)
|
||||
assert_equal('-0.0+0.0i', (Complex(-0.0, +0.0) - Complex(+0.0, -0.0)).to_s)
|
||||
assert_equal('0.0+0.0i', (Complex(-0.0, +0.0) * Complex(+0.0, -0.0)).to_s)
|
||||
assert_equal('-0.0+0.0i', (Complex(-0.0, +0.0) + Complex(-0.0, -0.0)).to_s)
|
||||
assert_equal('0.0+0.0i', (Complex(-0.0, +0.0) - Complex(-0.0, -0.0)).to_s)
|
||||
assert_equal('0.0+0.0i', (Complex(-0.0, +0.0) * Complex(-0.0, -0.0)).to_s)
|
||||
assert_equal('0.0-0.0i', (+Complex(+0.0, -0.0)).to_s)
|
||||
assert_equal('-0.0+0.0i', (-Complex(+0.0, -0.0)).to_s)
|
||||
assert_equal('0.0+0.0i', (Complex(+0.0, -0.0) + Complex(+0.0, +0.0)).to_s)
|
||||
assert_equal('0.0-0.0i', (Complex(+0.0, -0.0) - Complex(+0.0, +0.0)).to_s)
|
||||
assert_equal('0.0+0.0i', (Complex(+0.0, -0.0) * Complex(+0.0, +0.0)).to_s)
|
||||
assert_equal('0.0+0.0i', (Complex(+0.0, -0.0) + Complex(-0.0, +0.0)).to_s)
|
||||
assert_equal('0.0-0.0i', (Complex(+0.0, -0.0) - Complex(-0.0, +0.0)).to_s)
|
||||
assert_equal('0.0+0.0i', (Complex(+0.0, -0.0) * Complex(-0.0, +0.0)).to_s)
|
||||
assert_equal('0.0-0.0i', (Complex(+0.0, -0.0) + Complex(+0.0, -0.0)).to_s)
|
||||
assert_equal('0.0+0.0i', (Complex(+0.0, -0.0) - Complex(+0.0, -0.0)).to_s)
|
||||
assert_equal('0.0-0.0i', (Complex(+0.0, -0.0) * Complex(+0.0, -0.0)).to_s)
|
||||
assert_equal('0.0-0.0i', (Complex(+0.0, -0.0) + Complex(-0.0, -0.0)).to_s)
|
||||
assert_equal('0.0+0.0i', (Complex(+0.0, -0.0) - Complex(-0.0, -0.0)).to_s)
|
||||
assert_equal('-0.0+0.0i', (Complex(+0.0, -0.0) * Complex(-0.0, -0.0)).to_s)
|
||||
assert_equal('-0.0-0.0i', (+Complex(-0.0, -0.0)).to_s)
|
||||
assert_equal('0.0+0.0i', (-Complex(-0.0, -0.0)).to_s)
|
||||
assert_equal('0.0+0.0i', (Complex(-0.0, -0.0) + Complex(+0.0, +0.0)).to_s)
|
||||
assert_equal('-0.0-0.0i', (Complex(-0.0, -0.0) - Complex(+0.0, +0.0)).to_s)
|
||||
assert_equal('0.0-0.0i', (Complex(-0.0, -0.0) * Complex(+0.0, +0.0)).to_s)
|
||||
assert_equal('-0.0+0.0i', (Complex(-0.0, -0.0) + Complex(-0.0, +0.0)).to_s)
|
||||
assert_equal('0.0-0.0i', (Complex(-0.0, -0.0) - Complex(-0.0, +0.0)).to_s)
|
||||
assert_equal('0.0+0.0i', (Complex(-0.0, -0.0) * Complex(-0.0, +0.0)).to_s)
|
||||
assert_equal('0.0-0.0i', (Complex(-0.0, -0.0) + Complex(+0.0, -0.0)).to_s)
|
||||
assert_equal('-0.0+0.0i', (Complex(-0.0, -0.0) - Complex(+0.0, -0.0)).to_s)
|
||||
assert_equal('-0.0+0.0i', (Complex(-0.0, -0.0) * Complex(+0.0, -0.0)).to_s)
|
||||
assert_equal('-0.0-0.0i', (Complex(-0.0, -0.0) + Complex(-0.0, -0.0)).to_s)
|
||||
assert_equal('0.0+0.0i', (Complex(-0.0, -0.0) - Complex(-0.0, -0.0)).to_s)
|
||||
assert_equal('0.0+0.0i', (Complex(-0.0, -0.0) * Complex(-0.0, -0.0)).to_s)
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,407 @@
|
|||
require 'test/unit'
|
||||
|
||||
class ComplexRational_Test < Test::Unit::TestCase
|
||||
|
||||
def test_rat_srat
|
||||
return unless defined?(Rational)
|
||||
|
||||
c = SimpleRat(1,3)
|
||||
cc = Rational(3,2)
|
||||
|
||||
assert_kind_of(Numeric, c)
|
||||
assert_kind_of(Numeric, cc)
|
||||
|
||||
assert_instance_of(SimpleRat, c)
|
||||
assert_instance_of(Rational, cc)
|
||||
|
||||
assert_equal(SimpleRat(1,3), +c)
|
||||
assert_equal(SimpleRat(-1,3), -c)
|
||||
|
||||
assert_equal(SimpleRat(7,3), c + 2)
|
||||
assert_equal(SimpleRat(-5,3), c - 2)
|
||||
assert_equal(SimpleRat(2,3), c * 2)
|
||||
assert_equal(SimpleRat(1,6), c / 2)
|
||||
assert_equal(SimpleRat(1,9), c ** 2)
|
||||
assert_equal(-1, c <=> 2)
|
||||
|
||||
assert_equal(SimpleRat(7,3), 2 + c)
|
||||
assert_equal(SimpleRat(5,3), 2 - c)
|
||||
assert_equal(SimpleRat(2,3), 2 * c)
|
||||
assert_equal(SimpleRat(6,1), 2 / c)
|
||||
assert_in_delta(1.2599, 2 ** c, 0.001)
|
||||
assert_equal(1, 2 <=> c)
|
||||
|
||||
assert_equal(SimpleRat(11,6), c + cc)
|
||||
assert_equal(SimpleRat(-7,6), c - cc)
|
||||
assert_equal(SimpleRat(1,2), c * cc)
|
||||
assert_equal(SimpleRat(2,9), c / cc)
|
||||
assert_in_delta(0.1924, c ** cc, 0.001)
|
||||
assert_equal(-1, c <=> cc)
|
||||
|
||||
assert_equal(SimpleRat(11,6), cc + c)
|
||||
assert_equal(SimpleRat(7,6), cc - c)
|
||||
assert_equal(SimpleRat(1,2), cc * c)
|
||||
assert_equal(SimpleRat(9,2), cc / c)
|
||||
assert_in_delta(1.1447, cc ** c, 0.001)
|
||||
assert_equal(1, cc <=> c)
|
||||
|
||||
assert_equal(SimpleRat, (+c).class)
|
||||
assert_equal(SimpleRat, (-c).class)
|
||||
|
||||
assert_equal(SimpleRat, (c + 2).class)
|
||||
assert_equal(SimpleRat, (c - 2).class)
|
||||
assert_equal(SimpleRat, (c * 2).class)
|
||||
assert_equal(SimpleRat, (c / 2).class)
|
||||
assert_equal(SimpleRat, (c ** 2).class)
|
||||
|
||||
assert_equal(SimpleRat, (2 + c).class)
|
||||
assert_equal(SimpleRat, (2 - c).class)
|
||||
assert_equal(SimpleRat, (2 * c).class)
|
||||
assert_equal(SimpleRat, (2 / c).class)
|
||||
assert_equal(Float, (2 ** c).class)
|
||||
|
||||
assert_equal(SimpleRat, (c + cc).class)
|
||||
assert_equal(SimpleRat, (c - cc).class)
|
||||
assert_equal(SimpleRat, (c * cc).class)
|
||||
assert_equal(SimpleRat, (c / cc).class)
|
||||
assert_equal(Float, (c ** cc).class)
|
||||
|
||||
assert_equal(SimpleRat, (cc + c).class)
|
||||
assert_equal(SimpleRat, (cc - c).class)
|
||||
assert_equal(SimpleRat, (cc * c).class)
|
||||
assert_equal(SimpleRat, (cc / c).class)
|
||||
assert_equal(Float, (cc ** c).class)
|
||||
|
||||
assert_equal(0, Rational(2,3) <=> SimpleRat(2,3))
|
||||
assert_equal(0, SimpleRat(2,3) <=> Rational(2,3))
|
||||
assert(Rational(2,3) == SimpleRat(2,3))
|
||||
assert(SimpleRat(2,3) == Rational(2,3))
|
||||
|
||||
assert_equal(SimpleRat, (c + 0).class)
|
||||
assert_equal(SimpleRat, (c - 0).class)
|
||||
assert_equal(SimpleRat, (c * 0).class)
|
||||
assert_equal(SimpleRat, (c * 1).class)
|
||||
assert_equal(SimpleRat, (0 + c).class)
|
||||
assert_equal(SimpleRat, (0 - c).class)
|
||||
assert_equal(SimpleRat, (0 * c).class)
|
||||
assert_equal(SimpleRat, (1 * c).class)
|
||||
end
|
||||
|
||||
def test_comp_srat
|
||||
return unless defined?(Rational)
|
||||
|
||||
c = Complex(SimpleRat(2,3),SimpleRat(1,2))
|
||||
cc = Complex(Rational(3,2),Rational(2,1))
|
||||
|
||||
assert_equal(Complex(SimpleRat(2,3),SimpleRat(1,2)), +c)
|
||||
assert_equal(Complex(SimpleRat(-2,3),SimpleRat(-1,2)), -c)
|
||||
|
||||
assert_equal(Complex(SimpleRat(8,3),SimpleRat(1,2)), c + 2)
|
||||
assert_equal(Complex(SimpleRat(-4,3),SimpleRat(1,2)), c - 2)
|
||||
assert_equal(Complex(SimpleRat(4,3),SimpleRat(1,1)), c * 2)
|
||||
assert_equal(Complex(SimpleRat(1,3),SimpleRat(1,4)), c / 2)
|
||||
assert_equal(Complex(SimpleRat(7,36),SimpleRat(2,3)), c ** 2)
|
||||
assert_raise(NoMethodError){c <=> 2}
|
||||
|
||||
assert_equal(Complex(SimpleRat(8,3),SimpleRat(1,2)), 2 + c)
|
||||
assert_equal(Complex(SimpleRat(4,3),SimpleRat(-1,2)), 2 - c)
|
||||
assert_equal(Complex(SimpleRat(4,3),SimpleRat(1,1)), 2 * c)
|
||||
assert_equal(Complex(SimpleRat(48,25),SimpleRat(-36,25)), 2 / c)
|
||||
r = 2 ** c
|
||||
assert_in_delta(1.4940, r.real, 0.001)
|
||||
assert_in_delta(0.5392, r.imag, 0.001)
|
||||
assert_raise(NoMethodError){2 <=> c}
|
||||
|
||||
assert_equal(Complex(SimpleRat(13,6),SimpleRat(5,2)), c + cc)
|
||||
assert_equal(Complex(SimpleRat(-5,6),SimpleRat(-3,2)), c - cc)
|
||||
assert_equal(Complex(SimpleRat(0,1),SimpleRat(25,12)), c * cc)
|
||||
assert_equal(Complex(SimpleRat(8,25),SimpleRat(-7,75)), c / cc)
|
||||
r = c ** cc
|
||||
assert_in_delta(0.1732, r.real, 0.001)
|
||||
assert_in_delta(0.1186, r.imag, 0.001)
|
||||
assert_raise(NoMethodError){c <=> cc}
|
||||
|
||||
assert_equal(Complex(SimpleRat(13,6),SimpleRat(5,2)), cc + c)
|
||||
assert_equal(Complex(SimpleRat(5,6),SimpleRat(3,2)), cc - c)
|
||||
assert_equal(Complex(SimpleRat(0,1),SimpleRat(25,12)), cc * c)
|
||||
assert_equal(Complex(SimpleRat(72,25),SimpleRat(21,25)), cc / c)
|
||||
r = cc ** c
|
||||
assert_in_delta(0.5498, r.real, 0.001)
|
||||
assert_in_delta(1.0198, r.imag, 0.001)
|
||||
assert_raise(NoMethodError){cc <=> c}
|
||||
|
||||
assert_equal([SimpleRat,SimpleRat],
|
||||
(+c).instance_eval{[real.class, imag.class]})
|
||||
assert_equal([SimpleRat,SimpleRat],
|
||||
(-c).instance_eval{[real.class, imag.class]})
|
||||
|
||||
assert_equal([SimpleRat,SimpleRat],
|
||||
(c + 2).instance_eval{[real.class, imag.class]})
|
||||
assert_equal([SimpleRat,SimpleRat],
|
||||
(c - 2).instance_eval{[real.class, imag.class]})
|
||||
assert_equal([SimpleRat,SimpleRat],
|
||||
(c * 2).instance_eval{[real.class, imag.class]})
|
||||
assert_equal([SimpleRat,SimpleRat],
|
||||
(c / 2).instance_eval{[real.class, imag.class]})
|
||||
assert_equal([SimpleRat,SimpleRat],
|
||||
(c ** 2).instance_eval{[real.class, imag.class]})
|
||||
|
||||
assert_equal([SimpleRat,SimpleRat],
|
||||
(c + cc).instance_eval{[real.class, imag.class]})
|
||||
assert_equal([SimpleRat,SimpleRat],
|
||||
(c - cc).instance_eval{[real.class, imag.class]})
|
||||
assert_equal([SimpleRat,SimpleRat],
|
||||
(c * cc).instance_eval{[real.class, imag.class]})
|
||||
assert_equal([SimpleRat,SimpleRat],
|
||||
(c / cc).instance_eval{[real.class, imag.class]})
|
||||
assert_equal([Float,Float],
|
||||
(c ** cc).instance_eval{[real.class, imag.class]})
|
||||
|
||||
assert_equal([SimpleRat,SimpleRat],
|
||||
(cc + c).instance_eval{[real.class, imag.class]})
|
||||
assert_equal([SimpleRat,SimpleRat],
|
||||
(cc - c).instance_eval{[real.class, imag.class]})
|
||||
assert_equal([SimpleRat,SimpleRat],
|
||||
(cc * c).instance_eval{[real.class, imag.class]})
|
||||
assert_equal([SimpleRat,SimpleRat],
|
||||
(cc / c).instance_eval{[real.class, imag.class]})
|
||||
assert_equal([Float,Float],
|
||||
(cc ** c).instance_eval{[real.class, imag.class]})
|
||||
|
||||
assert(Complex(SimpleRat(2,3),SimpleRat(3,2)) ==
|
||||
Complex(Rational(2,3),Rational(3,2)))
|
||||
assert(Complex(Rational(2,3),Rational(3,2)) ==
|
||||
Complex(SimpleRat(2,3),SimpleRat(3,2)))
|
||||
|
||||
assert_equal([SimpleRat,SimpleRat],
|
||||
(c + 0).instance_eval{[real.class, imag.class]})
|
||||
assert_equal([SimpleRat,SimpleRat],
|
||||
(c - 0).instance_eval{[real.class, imag.class]})
|
||||
assert_equal([SimpleRat,SimpleRat],
|
||||
(c * 0).instance_eval{[real.class, imag.class]})
|
||||
assert_equal([SimpleRat,SimpleRat],
|
||||
(c * 1).instance_eval{[real.class, imag.class]})
|
||||
assert_equal([SimpleRat,SimpleRat],
|
||||
(0 + c).instance_eval{[real.class, imag.class]})
|
||||
assert_equal([SimpleRat,SimpleRat],
|
||||
(0 - c).instance_eval{[real.class, imag.class]})
|
||||
assert_equal([SimpleRat,SimpleRat],
|
||||
(0 * c).instance_eval{[real.class, imag.class]})
|
||||
assert_equal([SimpleRat,SimpleRat],
|
||||
(1 * c).instance_eval{[real.class, imag.class]})
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def SimpleRat(*a) SimpleRat.new(*a) end
|
||||
|
||||
class SimpleRat < Numeric
|
||||
|
||||
def initialize(num, den = 1)
|
||||
if den == 0
|
||||
raise ZeroDivisionError, "divided by zero"
|
||||
end
|
||||
if den < 0
|
||||
num = -num
|
||||
den = -den
|
||||
end
|
||||
gcd = num.gcd(den)
|
||||
@num = num.div(gcd)
|
||||
@den = den.div(gcd)
|
||||
end
|
||||
|
||||
def numerator() @num end
|
||||
def denominator() @den end
|
||||
|
||||
def +@ () self end
|
||||
def -@ () self.class.new(-@num, @den) end
|
||||
|
||||
def + (o)
|
||||
case o
|
||||
when SimpleRat, Rational
|
||||
a = @num * o.denominator
|
||||
b = o.numerator * @den
|
||||
self.class.new(a + b, @den * o.denominator)
|
||||
when Integer
|
||||
self + self.class.new(o)
|
||||
when Float
|
||||
to_f + o
|
||||
else
|
||||
x, y = o.coerce(self)
|
||||
x + y
|
||||
end
|
||||
end
|
||||
|
||||
def - (o)
|
||||
case o
|
||||
when SimpleRat, Rational
|
||||
a = @num * o.denominator
|
||||
b = o.numerator * @den
|
||||
self.class.new(a - b, @den * o.denominator)
|
||||
when Integer
|
||||
self - self.class.new(o)
|
||||
when Float
|
||||
to_f - o
|
||||
else
|
||||
x, y = o.coerce(self)
|
||||
x - y
|
||||
end
|
||||
end
|
||||
|
||||
def * (o)
|
||||
case o
|
||||
when SimpleRat, Rational
|
||||
a = @num * o.numerator
|
||||
b = @den * o.denominator
|
||||
self.class.new(a, b)
|
||||
when Integer
|
||||
self * self.class.new(o)
|
||||
when Float
|
||||
to_f * o
|
||||
else
|
||||
x, y = o.coerce(self)
|
||||
x * y
|
||||
end
|
||||
end
|
||||
|
||||
def quo(o)
|
||||
case o
|
||||
when SimpleRat, Rational
|
||||
a = @num * o.denominator
|
||||
b = @den * o.numerator
|
||||
self.class.new(a, b)
|
||||
when Integer
|
||||
if o == 0
|
||||
raise raise ZeroDivisionError, "divided by zero"
|
||||
end
|
||||
self.quo(self.class.new(o))
|
||||
when Float
|
||||
to_f.quo(o)
|
||||
else
|
||||
x, y = o.coerce(self)
|
||||
x.quo(y)
|
||||
end
|
||||
end
|
||||
|
||||
alias / quo
|
||||
|
||||
def floor
|
||||
@num.div(@den)
|
||||
end
|
||||
|
||||
def ceil
|
||||
-((-@num).div(@den))
|
||||
end
|
||||
|
||||
def truncate
|
||||
if @num < 0
|
||||
return -((-@num).div(@den))
|
||||
end
|
||||
@num.div(@den)
|
||||
end
|
||||
|
||||
alias to_i truncate
|
||||
|
||||
def round
|
||||
if @num < 0
|
||||
num = -@num
|
||||
num = num * 2 + @den
|
||||
den = @den * 2
|
||||
-(num.div(den))
|
||||
else
|
||||
num = @num * 2 + @den
|
||||
den = @den * 2
|
||||
num.div(den)
|
||||
end
|
||||
end
|
||||
|
||||
def div(o) (self / o).floor end
|
||||
def quot(o) (self / o).truncate end
|
||||
|
||||
def modulo(o)
|
||||
q = div(o)
|
||||
self - o * q
|
||||
end
|
||||
|
||||
def remainder(o)
|
||||
q = quot(o)
|
||||
self - o * q
|
||||
end
|
||||
|
||||
alias % modulo
|
||||
|
||||
def divmod(o) [div(o), modulo(o)] end
|
||||
def quotrem(o) [quot(o), remainder(o)] end
|
||||
|
||||
def ** (o)
|
||||
case o
|
||||
when SimpleRat, Rational
|
||||
Float(self) ** o
|
||||
when Integer
|
||||
if o > 0
|
||||
a = @num ** o
|
||||
b = @den ** o
|
||||
elsif o < 0
|
||||
a = @den ** -o
|
||||
b = @num ** -o
|
||||
else
|
||||
a = b = 1
|
||||
end
|
||||
self.class.new(a, b)
|
||||
when Float
|
||||
to_f ** o
|
||||
else
|
||||
x, y = o.coerce(self)
|
||||
x ** y
|
||||
end
|
||||
end
|
||||
|
||||
def <=> (o)
|
||||
case o
|
||||
when SimpleRat, Rational
|
||||
a = @num * o.denominator
|
||||
b = o.numerator * @den
|
||||
return a <=> b
|
||||
when Integer
|
||||
self <=> self.class.new(o)
|
||||
when Float
|
||||
to_f <=> o
|
||||
else
|
||||
x, y = o.coerce(self)
|
||||
x <=> y
|
||||
end
|
||||
end
|
||||
|
||||
def == (o)
|
||||
begin
|
||||
(self <=> o) == 0
|
||||
rescue
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
def coerce(o)
|
||||
case o
|
||||
when Rational
|
||||
[self.class.new(o.numerator, o.denominator), self]
|
||||
when Integer
|
||||
[self.class.new(o), self]
|
||||
when Float
|
||||
[o, self.to_f]
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
def hash() @num.hash ^ @den.hash end
|
||||
|
||||
def to_f() @num.to_f / @den.to_f end
|
||||
def to_r() self end
|
||||
def to_s() format('%s/%s', @num, @den) end
|
||||
|
||||
def inspect() format('#SR(%s)', to_s) end
|
||||
|
||||
def marshal_dump() [@num, @den] end
|
||||
def marshal_load(a) @num, @den = a end
|
||||
|
||||
end
|
|
@ -3,6 +3,8 @@ require 'test/unit'
|
|||
class Rational_Test2 < Test::Unit::TestCase
|
||||
|
||||
def test_kumi
|
||||
assert_equal(Rational(1, 1), +Rational(1, 1))
|
||||
assert_equal(Rational(-1, 1), -Rational(1, 1))
|
||||
assert_equal(Rational(2, 1),
|
||||
Rational(1, 1) + Rational(1, 1))
|
||||
assert_equal(Rational(0, 1),
|
||||
|
@ -107,6 +109,8 @@ class Rational_Test2 < Test::Unit::TestCase
|
|||
Rational(1, 1) * Rational(1073741827, 1073741789))
|
||||
assert_equal(Rational(1073741789, 1073741827),
|
||||
Rational(1, 1) / Rational(1073741827, 1073741789))
|
||||
assert_equal(Rational(2, 1), +Rational(2, 1))
|
||||
assert_equal(Rational(-2, 1), -Rational(2, 1))
|
||||
assert_equal(Rational(3, 1),
|
||||
Rational(2, 1) + Rational(1, 1))
|
||||
assert_equal(Rational(1, 1),
|
||||
|
@ -211,6 +215,8 @@ class Rational_Test2 < Test::Unit::TestCase
|
|||
Rational(2, 1) * Rational(1073741827, 1073741789))
|
||||
assert_equal(Rational(2147483578, 1073741827),
|
||||
Rational(2, 1) / Rational(1073741827, 1073741789))
|
||||
assert_equal(Rational(3, 1), +Rational(3, 1))
|
||||
assert_equal(Rational(-3, 1), -Rational(3, 1))
|
||||
assert_equal(Rational(4, 1),
|
||||
Rational(3, 1) + Rational(1, 1))
|
||||
assert_equal(Rational(2, 1),
|
||||
|
@ -315,6 +321,8 @@ class Rational_Test2 < Test::Unit::TestCase
|
|||
Rational(3, 1) * Rational(1073741827, 1073741789))
|
||||
assert_equal(Rational(3221225367, 1073741827),
|
||||
Rational(3, 1) / Rational(1073741827, 1073741789))
|
||||
assert_equal(Rational(1073741789, 1), +Rational(1073741789, 1))
|
||||
assert_equal(Rational(-1073741789, 1), -Rational(1073741789, 1))
|
||||
assert_equal(Rational(1073741790, 1),
|
||||
Rational(1073741789, 1) + Rational(1, 1))
|
||||
assert_equal(Rational(1073741788, 1),
|
||||
|
@ -419,6 +427,8 @@ class Rational_Test2 < Test::Unit::TestCase
|
|||
Rational(1073741789, 1) * Rational(1073741827, 1073741789))
|
||||
assert_equal(Rational(1152921429444920521, 1073741827),
|
||||
Rational(1073741789, 1) / Rational(1073741827, 1073741789))
|
||||
assert_equal(Rational(1073741827, 1), +Rational(1073741827, 1))
|
||||
assert_equal(Rational(-1073741827, 1), -Rational(1073741827, 1))
|
||||
assert_equal(Rational(1073741828, 1),
|
||||
Rational(1073741827, 1) + Rational(1, 1))
|
||||
assert_equal(Rational(1073741826, 1),
|
||||
|
@ -523,6 +533,8 @@ class Rational_Test2 < Test::Unit::TestCase
|
|||
Rational(1073741827, 1) * Rational(1073741827, 1073741789))
|
||||
assert_equal(Rational(1073741789, 1),
|
||||
Rational(1073741827, 1) / Rational(1073741827, 1073741789))
|
||||
assert_equal(Rational(2, 3), +Rational(2, 3))
|
||||
assert_equal(Rational(-2, 3), -Rational(2, 3))
|
||||
assert_equal(Rational(5, 3),
|
||||
Rational(2, 3) + Rational(1, 1))
|
||||
assert_equal(Rational(-1, 3),
|
||||
|
@ -627,6 +639,8 @@ class Rational_Test2 < Test::Unit::TestCase
|
|||
Rational(2, 3) * Rational(1073741827, 1073741789))
|
||||
assert_equal(Rational(2147483578, 3221225481),
|
||||
Rational(2, 3) / Rational(1073741827, 1073741789))
|
||||
assert_equal(Rational(3, 2), +Rational(3, 2))
|
||||
assert_equal(Rational(-3, 2), -Rational(3, 2))
|
||||
assert_equal(Rational(5, 2),
|
||||
Rational(3, 2) + Rational(1, 1))
|
||||
assert_equal(Rational(1, 2),
|
||||
|
@ -731,6 +745,8 @@ class Rational_Test2 < Test::Unit::TestCase
|
|||
Rational(3, 2) * Rational(1073741827, 1073741789))
|
||||
assert_equal(Rational(3221225367, 2147483654),
|
||||
Rational(3, 2) / Rational(1073741827, 1073741789))
|
||||
assert_equal(Rational(3, 1073741789), +Rational(3, 1073741789))
|
||||
assert_equal(Rational(-3, 1073741789), -Rational(3, 1073741789))
|
||||
assert_equal(Rational(1073741792, 1073741789),
|
||||
Rational(3, 1073741789) + Rational(1, 1))
|
||||
assert_equal(Rational(-1073741786, 1073741789),
|
||||
|
@ -835,6 +851,8 @@ class Rational_Test2 < Test::Unit::TestCase
|
|||
Rational(3, 1073741789) * Rational(1073741827, 1073741789))
|
||||
assert_equal(Rational(3, 1073741827),
|
||||
Rational(3, 1073741789) / Rational(1073741827, 1073741789))
|
||||
assert_equal(Rational(1073741789, 3), +Rational(1073741789, 3))
|
||||
assert_equal(Rational(-1073741789, 3), -Rational(1073741789, 3))
|
||||
assert_equal(Rational(1073741792, 3),
|
||||
Rational(1073741789, 3) + Rational(1, 1))
|
||||
assert_equal(Rational(1073741786, 3),
|
||||
|
@ -939,6 +957,8 @@ class Rational_Test2 < Test::Unit::TestCase
|
|||
Rational(1073741789, 3) * Rational(1073741827, 1073741789))
|
||||
assert_equal(Rational(1152921429444920521, 3221225481),
|
||||
Rational(1073741789, 3) / Rational(1073741827, 1073741789))
|
||||
assert_equal(Rational(3, 1073741827), +Rational(3, 1073741827))
|
||||
assert_equal(Rational(-3, 1073741827), -Rational(3, 1073741827))
|
||||
assert_equal(Rational(1073741830, 1073741827),
|
||||
Rational(3, 1073741827) + Rational(1, 1))
|
||||
assert_equal(Rational(-1073741824, 1073741827),
|
||||
|
@ -1043,6 +1063,8 @@ class Rational_Test2 < Test::Unit::TestCase
|
|||
Rational(3, 1073741827) * Rational(1073741827, 1073741789))
|
||||
assert_equal(Rational(3221225367, 1152921511049297929),
|
||||
Rational(3, 1073741827) / Rational(1073741827, 1073741789))
|
||||
assert_equal(Rational(1073741827, 3), +Rational(1073741827, 3))
|
||||
assert_equal(Rational(-1073741827, 3), -Rational(1073741827, 3))
|
||||
assert_equal(Rational(1073741830, 3),
|
||||
Rational(1073741827, 3) + Rational(1, 1))
|
||||
assert_equal(Rational(1073741824, 3),
|
||||
|
@ -1147,6 +1169,8 @@ class Rational_Test2 < Test::Unit::TestCase
|
|||
Rational(1073741827, 3) * Rational(1073741827, 1073741789))
|
||||
assert_equal(Rational(1073741789, 3),
|
||||
Rational(1073741827, 3) / Rational(1073741827, 1073741789))
|
||||
assert_equal(Rational(1073741789, 1073741827), +Rational(1073741789, 1073741827))
|
||||
assert_equal(Rational(-1073741789, 1073741827), -Rational(1073741789, 1073741827))
|
||||
assert_equal(Rational(2147483616, 1073741827),
|
||||
Rational(1073741789, 1073741827) + Rational(1, 1))
|
||||
assert_equal(Rational(-38, 1073741827),
|
||||
|
@ -1251,6 +1275,8 @@ class Rational_Test2 < Test::Unit::TestCase
|
|||
Rational(1073741789, 1073741827) * Rational(1073741827, 1073741789))
|
||||
assert_equal(Rational(1152921429444920521, 1152921511049297929),
|
||||
Rational(1073741789, 1073741827) / Rational(1073741827, 1073741789))
|
||||
assert_equal(Rational(1073741827, 1073741789), +Rational(1073741827, 1073741789))
|
||||
assert_equal(Rational(-1073741827, 1073741789), -Rational(1073741827, 1073741789))
|
||||
assert_equal(Rational(2147483616, 1073741789),
|
||||
Rational(1073741827, 1073741789) + Rational(1, 1))
|
||||
assert_equal(Rational(38, 1073741789),
|
||||
|
|
Загрузка…
Ссылка в новой задаче