mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* numeric.c (fix_pow): integer power calculation: 0**n => 0,
1**n => 1, -1**n => 1 (n: even) / -1 (n: odd). * test/ruby/test_fixnum.rb (TestFixnum::test_pow): update test suite. pow(-3, 2^64) gives NaN when pow(3, 2^64) gives Inf. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12789 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
bb44ba9b72
commit
7f0bb427e0
3 changed files with 29 additions and 6 deletions
|
@ -12,7 +12,7 @@ class TestFixnum < Test::Unit::TestCase
|
|||
|
||||
def test_pow
|
||||
[1, 2, 2**64, 2**63*3, 2**64*3].each do |y|
|
||||
[1, 3].each do |x|
|
||||
[-1, 0, 1].each do |x|
|
||||
z1 = x**y
|
||||
z2 = (-x)**y
|
||||
if y % 2 == 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue