From: Brian Candler Date: 2012-03-25T02:22:59+09:00 Subject: Re: Ruby speed compared to C in a simple calculations. "Роман Ткаленко" wrote in post #1053071: > #works for 3.55 mins > P = 295075153 > o1 = 210205973 > o2 = 22795300 > (0 .. P).each do | i | > if i ^ (i ^ o1) == o1 and ((i * 2 + 5) % P) ^ (((i ^ o1) * 3 + 7) % > P) > == o2 > puts i > break > end > end > Code written in C gives me the solution in only 2 seconds. Does the C code just use int64's? In ruby, integer values transparently extend from Fixnum to Bignum, so there's never any overflow. But this means that every integer value is an object and there has to be dynamic method dispatch for each arithmetic operation. You can always embed snippets of C into Ruby - look at RubyInline. -- Posted via http://www.ruby-forum.com/.