[ruby-core:66217] [ruby-trunk - Bug #10306] BigNum error

From: max.bacoux@...
Date: 2014-11-11 23:30:07 UTC
List: ruby-core #66217
Issue #10306 has been updated by Max Bacoux.


My bad, copy-pasted the wrong line from irb during some test, i'm sorry.

Anyways, the problem arise when you do 1000000 ** 99999

~~~
1000000 ** 99999
 => 99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999995084223284714385362871051527436447723160446818498959988211353135636965138570438599063576816273102709478518085193131290467462906404806976488907525699971444534907380395005541372243400335999766976532174448197

(Hundred more lines ...)

33337324537194556352749757443571869265512805361814821187272469723152678229173033451212668533651537920
~~~

It's obviously not the right result. As BigInt is supposed to have absolute precision, there is probably an issue here.

Again, sorry for mis-reporting the issue in the original bug report. I hope it's correct now.

----------------------------------------
Bug #10306: BigNum error
https://bugs.ruby-lang.org/issues/10306#change-49907

* Author: Max Bacoux
* Status: Feedback
* Priority: Low
* Assignee: 
* Category: core
* Target version: 
* ruby -v: ruby 2.1.3p242 (2014-09-19 revision 47630) [x86_64-darwin13.0]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
Some calculations are wrong when dealing with large bignums.

For example, try 1000000000 ** 99, the result is obviously not right.



-- 
https://bugs.ruby-lang.org/

In This Thread

Prev Next