Boost logo

Boost :

From: Philippe Lalande (plalande-boost_at_[hidden])
Date: 2002-05-10 08:52:19


Markus Schöpflin (markus.schoepflin_at_[hidden]) wrote:
> The root of the problem is that you get quite some interesting
> results when doing signed integer division on this compiler.
> Try it with the following little program. :-)

I am not sure if it is really a compiler bug. gcc 2.95.2 results to your
program is un-intuitive either as b's value is 2147483647 (same as
MSVC6SP5).

The reason for this is that to be able to divide -2 by a unsigned
number, it is first cast to an unsigned (value of 4294967294) and then
divided. Since the resulting value is already in the signed ranged, it
is not converted back to a negative number.

With the values of the constant being smaller than INT_MAX, it would be
possible to convert declaration to signed or explicitely casting them as
signed when used in expression with other signed numbers.

Philippe


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk