From: Garance A Drosehn Date: 2005-07-05T07:22:05+09:00 Subject: Ruby2c and large numbers Checking out the writeup on Ruby2C at: http://www.zenspider.com/~ryand/Ruby2C.pdf there is one thing about the example on page 25 (of the pdf) which concerns me a little bit. The example has: class MyTest def factorial(n) f = 1 n.downto(2) { |x| f *= x } return f end end turn into: static VALUE factorial(VALUE self, VALUE _n) { long n = NUM2INT(_n); long f; long x; f = 1; x = n; while (x >= 2) { f = f * x; x = x - 1; }; return INT2NUM(f); } One nice thing about ruby is that the programmer does not have to worry about supported-ranges for integer values. Ruby just switches from "fixnum" objects into "bignum" objects, without any attention from the programmer. It seems to me that the C code that is listed above just assumes the multiplication of 'f * x' will not overflow. Is that the case? -- Garance Alistair Drosehn = drosihn@gmail.com