On Fri, Feb 10, 2006 at 10:52:42AM +0100, Leopold Toetsch wrote: > > On Feb 10, 2006, at 3:15, Joshua Isom wrote: > > [ quoting rearranged - please don't toppost ] > > >On Feb 9, 2006, at 6:20 PM, Leopold Toetsch wrote: > > >>$ cat div.pasm > >>set I0, 0x80000000 > >>div I1, I0, -1 > >>print I1 > >>print "\n" > >>end
> > But out of curiosity, why would integer division be a floating point > >exception? > > Lack of interrupt slots on x86? > > And why doesn't it set the overflow bit? > > > > >Oh, and on my iBook g3, I get -1. > > Wow. Now I think I see why the C standard has overflowing signed integer arithmetic as undefined behaviour... Perl 5 on x86-FreeBSD coredumps: $ ./perl -Ilib -wle 'use integer; $a = 0x80000000; print $a / -1' Floating point exception (core dumped) which I never knew. Beware of assuming anything about signed integer arithmetic overflow - the vendor compiler on 64 bit Irix produces the arithmetic results that you'd expect from 2's complement, but subsequent comparisons with the result don't always "work" (eg you end up down the "wrong" side of if statements) and on Ahmdal mainframes (IIRC) MAX_INT + 1 is 0, not MIN_INT. Nicholas Clark