[#100309] How to use backport custom field — Jun Aruga <jaruga@...>
Please allow my ignorance.
9 messages
2020/10/06
[#100310] Re: How to use backport custom field
— "NARUSE, Yui" <naruse@...>
2020/10/06
"Backport custom field" is only available for tickets whose tracker is "Bug".
[#100311] Re: How to use backport custom field
— Jun Aruga <jaruga@...>
2020/10/06
On Tue, Oct 6, 2020 at 4:44 PM NARUSE, Yui <naruse@airemix.jp> wrote:
[#100314] Re: How to use backport custom field
— "NARUSE, Yui" <naruse@...>
2020/10/06
Thank you for confirmation.
[#100322] Re: How to use backport custom field
— Jun Aruga <jaruga@...>
2020/10/07
On Tue, Oct 6, 2020 at 7:25 PM NARUSE, Yui <naruse@airemix.jp> wrote:
[#100326] Re: How to use backport custom field
— "NARUSE, Yui" <naruse@...>
2020/10/07
I added you to "Reporter" role in the project
[#100327] Re: How to use backport custom field
— Jun Aruga <jaruga@...>
2020/10/07
On Wed, Oct 7, 2020 at 1:42 PM NARUSE, Yui <naruse@airemix.jp> wrote:
[#100358] [BUG] ruby 2.6.6 warning with encdb.so — shiftag <shiftag@...>
Hello,
1 message
2020/10/10
[ruby-core:100379] [Ruby master Bug#17257] Integer#pow(0, 1) returns 1, which is incorrect
From:
mame@...
Date:
2020-10-12 04:35:01 UTC
List:
ruby-core #100379
Issue #17257 has been updated by mame (Yusuke Endoh).
I agree that it is a bug. The pseudocode of modular exponentiation in Wikipedia includes `if modulus = 1 then return 0` as the first check.
https://en.wikipedia.org/wiki/Modular_exponentiation#Pseudocode
I agree that there are few real use cases of modulo 1, so few one will be affected by this change. I'll fix it soon.
```diff
diff --git a/bignum.c b/bignum.c
index 65a50ea9ba..0515e2f0d6 100644
--- a/bignum.c
+++ b/bignum.c
@@ -7136,6 +7136,7 @@ rb_int_powm(int const argc, VALUE * const argv, VALUE const num)
long const half_val = (long)HALF_LONG_MSB;
long const mm = FIX2LONG(m);
if (!mm) rb_num_zerodiv();
+ if (mm == 1) return INT2FIX(0);
if (mm <= half_val) {
return int_pow_tmp1(rb_int_modulo(a, m), b, mm, nega_flg);
}
@@ -7145,6 +7146,7 @@ rb_int_powm(int const argc, VALUE * const argv, VALUE const num)
}
else {
if (rb_bigzero_p(m)) rb_num_zerodiv();
+ if (bignorm(m) == INT2FIX(1)) return INT2FIX(0);
return int_pow_tmp3(rb_int_modulo(a, m), b, m, nega_flg);
}
}
```
----------------------------------------
Bug #17257: Integer#pow(0, 1) returns 1, which is incorrect
https://bugs.ruby-lang.org/issues/17257#change-87990
* Author: universato (Yoshimine Sato)
* Status: Assigned
* Priority: Normal
* Assignee: mrkn (Kenta Murata)
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
Ruby 2.5.8, 2.6.6, 2.7.1
```ruby
p -1.pow(0, 1) #=> 1
p 0.pow(0, 1) #=> 1
p 1.pow(0, 1) #=> 1
p 1234567890.pow(0, 1) #=> 1
```
These return values should be 0.
Patch for test:
Let's add some boundary value tests to `test_pow` of [test_numeric.rb](https://github.com/ruby/ruby/blob/e014e6bf6685f681998238ff005f6d161d43ce51/test/ruby/test_numeric.rb).
```ruby
integers = [-2, -1, 0, 1, 2, 3, 6, 1234567890123456789]
integers.each do |i|
assert_equal(0, i.pow(0, 1), '[Bug #17257]')
assert_equal(1, i.pow(0, 2))
assert_equal(1, i.pow(0, 3))
assert_equal(1, i.pow(0, 6))
assert_equal(1, i.pow(0, 1234567890123456789))
assert_equal(0, i.pow(0, -1))
assert_equal(-1, i.pow(0, -2))
assert_equal(-2, i.pow(0, -3))
assert_equal(-5, i.pow(0, -6))
assert_equal(-1234567890123456788, i.pow(0, -1234567890123456789))
end
assert_equal(0, 0.pow(2, 1))
assert_equal(0, 0.pow(3, 1))
assert_equal(0, 2.pow(3, 1))
assert_equal(0, -2.pow(3, 1))
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>