* lib/cmath.rb (CMath.sqrt): use floating-point value. [ruby-core:31672] [Bug #3678]
* test/test_cmath.rb: added for testing lib/cmath.rb. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28964 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c89bdea7c9
commit
9b0b9ac237
@ -1,3 +1,10 @@
|
|||||||
|
Wed Aug 11 23:28:22 2010 Kenta Murata <mrkn@mrkn.jp>
|
||||||
|
|
||||||
|
* lib/cmath.rb (CMath.sqrt): use floating-point value.
|
||||||
|
[ruby-core:31672] [Bug #3678]
|
||||||
|
|
||||||
|
* test/test_cmath.rb: added for testing lib/cmath.rb.
|
||||||
|
|
||||||
Wed Aug 11 20:57:25 2010 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
|
Wed Aug 11 20:57:25 2010 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
|
||||||
|
|
||||||
* NEWS: merge from branches/ruby_1_9_2, and move io/console.
|
* NEWS: merge from branches/ruby_1_9_2, and move io/console.
|
||||||
|
@ -79,7 +79,7 @@ module CMath
|
|||||||
else
|
else
|
||||||
r = z.abs
|
r = z.abs
|
||||||
x = z.real
|
x = z.real
|
||||||
Complex(sqrt!((r + x) / 2), sqrt!((r - x) / 2))
|
Complex(sqrt!((r + x) / 2.0), sqrt!((r - x) / 2.0))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
8
test/test_cmath.rb
Normal file
8
test/test_cmath.rb
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
require 'test/unit'
|
||||||
|
require 'cmath'
|
||||||
|
|
||||||
|
class TestCMath < Test::Unit::TestCase
|
||||||
|
def test_sqrt
|
||||||
|
assert_equal CMath.sqrt(1.0.i), CMath.sqrt(1.i), '[ruby-core:31672]'
|
||||||
|
end
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user