Project

General

Profile

Actions

Bug #14259

closed

Integer#pow returns an invalid result with large modulo

Bug #14259: Integer#pow returns an invalid result with large modulo

Added by mrkn (Kenta Murata) almost 8 years ago. Updated over 5 years ago.

Status:
Closed
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 results should be 12.

Updated by mrkn (Kenta Murata) almost 8 years ago Actions #1

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

Updated by mrkn (Kenta Murata) almost 8 years ago Actions #2

  • 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] [ruby-core:84562]

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

Updated by mrkn (Kenta Murata) almost 8 years ago Actions #3

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

Updated by andrykonchin (Andrew Konchin) almost 8 years ago Actions #4 [ruby-core:84566]

Another example:

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

Expected following result:

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

Updated by naruse (Yui NARUSE) almost 8 years ago Actions #5 [ruby-core:84692]

  • 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.

Updated by usa (Usaku NAKAMURA) almost 8 years ago Actions #6

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

Updated by sawa (Tsuyoshi Sawada) over 5 years ago Actions #7

  • Subject changed from Integer#pow returns a Invalid result with a large modulo to Integer#pow returns an invalid result with large modulo
  • Description updated (diff)
Actions

Also available in: PDF Atom