Boost logo

Boost :

From: Pete Becker (petebecker_at_[hidden])
Date: 2002-05-10 09:13:59


At 03:24 PM 5/10/2002 +0200, Markus Schöpflin wrote:
> unsigned long a = 2;
> signed long b = -2 / a;

As Dave pointed out, this isn't a bug; -2 is of type int, and it gets
promoted to unsigned long for the division. This (correctly) produces a
large value.

I haven't looked at to_duration, but I remember struggling with the
analogous code in our implementation. Mixing signed and unsigned types can
be hazardous to your sanity.

        -- Pete

Dinkumware, Ltd.
"Genuine Software"


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