Do C++ signed types have modulo semantics?

Nathan Sidwell nathan@codesourcery.com
Tue Jun 28 15:49:00 GMT 2005


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



More information about the Gcc mailing list