зеркало из https://github.com/github/ruby.git
`Integer#pow(b)` accepts numeric
instead of integer only and returns numeric instead of integer only same as `Integer#**` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61058 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
956cfb974f
Коммит
49dc866492
2
bignum.c
2
bignum.c
|
@ -7028,7 +7028,7 @@ int_pow_tmp2(VALUE x, VALUE y, long mm, int nega_flg)
|
||||||
/*
|
/*
|
||||||
* Document-method: Integer#pow
|
* Document-method: Integer#pow
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* integer.pow(integer) -> integer
|
* integer.pow(numeric) -> numeric
|
||||||
* integer.pow(integer, integer) -> integer
|
* integer.pow(integer, integer) -> integer
|
||||||
*
|
*
|
||||||
* Returns (modular) exponentiation as:
|
* Returns (modular) exponentiation as:
|
||||||
|
|
|
@ -386,6 +386,10 @@ class TestNumeric < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_pow
|
def test_pow
|
||||||
|
assert_equal(2**3, 2.pow(3))
|
||||||
|
assert_equal(2**-1, 2.pow(-1))
|
||||||
|
assert_equal(2**0.5, 2.pow(0.5))
|
||||||
|
assert_equal((-1)**0.5, -1.pow(0.5))
|
||||||
assert_equal(3**3 % 8, 3.pow(3, 8))
|
assert_equal(3**3 % 8, 3.pow(3, 8))
|
||||||
assert_equal(3**3 % -8, 3.pow(3,-8))
|
assert_equal(3**3 % -8, 3.pow(3,-8))
|
||||||
assert_equal(3**2 % -2, 3.pow(2,-2))
|
assert_equal(3**2 % -2, 3.pow(2,-2))
|
||||||
|
|
Загрузка…
Ссылка в новой задаче