Project

General

Profile

Bug #14259

Integer#pow returns a Invalid result with a large modulo

Added by mrkn (Kenta Murata) 5 months ago. Updated 5 months 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 f9292492
Added by mrkn (Kenta Murata) 5 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.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61517 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 61517
Added by mrkn (Kenta Murata) 5 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.

Revision a697c8b6
Added by naruse (Yui NARUSE) 5 months ago

merge revision(s) 61517: [Backport #14259]

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.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_5@61629 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 61629
Added by naruse (Yui NARUSE) 5 months ago

merge revision(s) 61517: [Backport #14259]

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) 5 months ago

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

#2 Updated by mrkn (Kenta Murata) 5 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) 5 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) 5 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) 5 months 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) 5 months 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