Hi, 2009/11/10 Marc-Andre Lafortune <redmine / ruby-lang.org>: > I'm quite ignorant about the differences between compilers and implementations (and I wouldn't mind remaining this way! ;-) > > The fact is, Ruby _already_ generates infinities. Line 2471 of numeric.c: > > #define infinite_value() ruby_div0(1.0) FYI, I heard that some compilers doesn't permit zero divisions by literals, but the following code can be used to avoid the check: tmp = 1.0; inf = 1.0 / (tmp - tmp); GNU Octave has more complicated code to generate an infinity: volatile double tmp_inf; #if defined (SCO) volatile double tmp = 1.0; tmp_inf = 1.0 / (tmp - tmp); #elif defined (__alpha__) && defined (__osf__) extern unsigned int DINFINITY[2]; tmp_inf = (*(X_CAST(double *, DINFINITY))); #else double tmp = 1e+10; tmp_inf = tmp; for (;;) { tmp_inf *= 1e+10; if (tmp_inf == tmp) break; tmp = tmp_inf; } -- Shugo Maeda