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

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.


Boost list run by bdawes at, gregod at, cpdaniel at, john at