This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Do C++ signed types have modulo semantics?
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: Michael Veksler <VEKSLER at il dot ibm dot com>
- Cc: Gabriel Dos Reis <gdr at integrable-solutions dot net>, gcc mailing list <gcc at gcc dot gnu dot org>,Andrew Pinski <pinskia at physics dot uc dot edu>, gcc mailing list <gcc at gcc dot gnu dot org>
- Date: Tue, 28 Jun 2005 16:48:26 +0100
- Subject: Re: Do C++ signed types have modulo semantics?
- References: <OF8C53C77B.667A02DE-ON4325702E.00541FD7-4325702E.005534DD@il.ibm.com>
Michael Veksler wrote:
So what does gcc gives for (int) (MAX_INT+1U)?
Maybe it is constrained such that
(int)(unsigned)a == a
For 1's complement the reverse seems to be incorrect:
unsigned a= 0xFFFFFFFF; // or was it 0x80000000?
assert((unsigned)(int)a == a); // may fail
why are you talking about one's complement in the context of gcc. From
implement-c.texi
@cite{Whether signed integer types are represented using sign and magnitude,
two's complement, or one's complement, and whether the extraordinary value
is a trap representation or an ordinary value (C99 6.2.6.2).}
GCC supports only two's complement integer types, and all bit patterns
are ordinary values.
please stop considering non 2's complement stuff.
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk