On 09/07/2006, at 8:17 PM, Tom Rauchenwald wrote: > "Tim Hollingsworth" <timhollingsworth / gmail.com> writes: > >> Hello >> >> First post here, by the way. Greetings to all:) New to ruby, love >> it, slaps >> on backs all round. >> >> While I haven't solved the pangram problem, I did find what >> appears to be a >> bug in Numeric.divmod on large numbers, as can be seen when using >> Bignum.modulo: >> >> irb(main):017:0> 1e22 % 1e21 >> => 0.0 >> irb(main):018:0> 1e23 % 1e22 >> => 9.99999999999999e+021 >> >> whoops! > > Not quite. 1e23 is a float, that's why you run into precision > problems. This has been discussed here not long ago. > If you use Bignums it works as expected: > > ,---- > | irb(main):001:0> 1e23.class > | => Float > | irb(main):002:0> (10**23).class > | => Bignum > | irb(main):003:0> 10**23 % 10**22 > | => 0 > `---- > > Tom > aha right you are! I was using to_i in my code, and there lies my problem.