Project

General

Profile

Actions

Bug #14259

closed

Integer#pow returns an invalid result with large modulo

Added by mrkn (Kenta Murata) almost 7 years ago. Updated over 4 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.

Actions #1

Updated by mrkn (Kenta Murata) almost 7 years ago

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

Updated by mrkn (Kenta Murata) almost 7 years 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] [ruby-core:84562]

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

Actions #3

Updated by mrkn (Kenta Murata) almost 7 years ago

  • 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 7 years ago

Another example:

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

Expected following result:

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

Updated by naruse (Yui NARUSE) almost 7 years 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.

Actions #6

Updated by usa (Usaku NAKAMURA) almost 7 years ago

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

Updated by sawa (Tsuyoshi Sawada) over 4 years ago

  • 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: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0