Project

General

Profile

Bug #14259

Integer#pow returns a Invalid result with a large modulo

Added by mrkn (Kenta Murata) about 2 months ago. Updated about 1 month ago.

Status:
Closed
Priority:
Normal
Target version:
-
ruby -v:
ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin16]
[ruby-core:84562]

Description

irb(main):020:0> 12.pow(1, 10000000000)
=> 1
irb(main):021:0> 12.pow(1, 10000000001)
=> 1
irb(main):022:0> 12.pow(1, 10000000002)
=> 1

These result should be 12.

Associated revisions

Revision 61517
Added by mrkn (Kenta Murata) about 2 months ago

numeric.c: Fix Integer#pow with a large Fixnum modulo

  • numeric.c: Fix Integer#pow with a large Fixnum modulo
    [Bug #14259]

  • test/ruby/test_numeric.rb: add assertions for reproducing this bug.

History

#1 Updated by mrkn (Kenta Murata) about 2 months ago

  • ruby -v set to ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin16]

#2 Updated by mrkn (Kenta Murata) about 2 months ago

  • Status changed from Assigned to Closed

Applied in changeset trunk|r61517.


numeric.c: Fix Integer#pow with a large Fixnum modulo

  • numeric.c: Fix Integer#pow with a large Fixnum modulo
    [Bug #14259]

  • test/ruby/test_numeric.rb: add assertions for reproducing this bug.

#3 Updated by mrkn (Kenta Murata) about 2 months ago

  • Backport changed from 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN to 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: REQUIRED

#4 [ruby-core:84566] Updated by andrykonchin (Andrew Konchin) about 2 months ago

Another example:

2.pow(61, 9213693951) # => 1

Expected following result:

(2 ** 61) % 9213693951 # => 5432161352

#5 [ruby-core:84692] Updated by naruse (Yui NARUSE) about 1 month ago

  • Backport changed from 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: REQUIRED to 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: DONE

ruby_2_5 r61629 merged revision(s) 61517.

#6 Updated by usa (Usaku NAKAMURA) about 1 month ago

  • Backport changed from 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: DONE to 2.3: DONTNEED, 2.4: DONTNEED, 2.5: DONE

Also available in: Atom PDF