in reply to Surviving 'Illegal division by zero'
...but it turns out that perl is too smart and catches these types of errors before passing them on to the hardware. Does anyone know if there is a compiler flag for perl which would disable these checks? Just for the fun of it I compiled up a version of perl which commented out the divide by zero check (in pp.c)...$SIG{FPE}=sub{...};
...make, compile, run.../*if (right == 0.0) DIE(aTHX_ "Illegal division by zero");*/
...looks like we're going down the right track...$ ./perl -e '$a=1.23/0.00;print "\$a=$a\n"' $a=inf
...make, compile, rerun...if (right == 0.0) PUSHs(&PL_sv_undef);/*DIE(aTHX_ "Illegal division by zero");*/ else PUSHn( left / right );
Of course you'd probably want to take care of the integer division case also.$ ./perl -e 'print "UNDEFINED\n" unless (defined(1.23/0.00))' UNDEFINED
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Signals and floating point exceptions
by theorbtwo (Prior) on Jun 25, 2004 at 02:00 UTC |