[PPL-devel] [Xsb-development] Arithmetic evaluation bug in the CVS HEAD version of XSB

David Warren warren at cs.sunysb.edu
Sun Sep 23 23:37:06 CEST 2007


Friends,

Sorry I'm a latecomer to this party, but I do have one comment:

Terrance Swift writes:
 > 
 > > | ?- -2147483648 < 2147483647 .
 > >
 > > ++Error[XSB]: [Runtime/C] Overflow in integer, returning MAX_INT
 > >
 > > no
 > > | ?- -2147483648 < 1 .
 > >
 > > ++Error[XSB]: [Runtime/C] Overflow in integer, returning MAX_INT
 > >
 > > yes

I recently did some work on integer overflow in the tokenizer.
Previously, it was pretty bad in XSB.  I tried to make it less bad.
The above is one problem I punted.  -2147483648, the smallest 32-bit
integer, is flagged incorrectly as overflow, as shown here.  The
problem is that it's not easy in the XSB tokenizer to determine when
processing an integer whether it is positive or negative; they
essentially are all initially treated as positive.  So since
2147483648 *is* an overflow, I took the easy way out and flagged it an
error even in the case in which it would be turned negative, and so be
OK.  That was my laziness.  (Bart, do you have a practical example in
which it was critical to have that one, rather special, negative
integer? :-).

Now:
 > > | ?- -2 < 2147483647 .
 > >
 > > no

This is quite troubling.  I will look into it.

-David



More information about the PPL-devel mailing list