rubybigintegerbug-reporting

Ruby Bignum broken?


I am trying to calculate the factorial of large numbers.

def fact(n)
  num = 1
  for i in 1..n
     num *= i
  end
  num
end
fact(90000)

With Ruby 2.2.0 using the code above, I get the result that ends with a bunch of 0's as expected, but with 2.1.1p76, I get a number ending with ...818500998068961280. Is this a problem with Ruby?


Solution

  • It looks to be an issue with ruby 2.1.1p76. I was able to reproduce getting a number ending in 67818500998068961280. However it does seem to work fine in 2.2.0.