GCC 3.3.1, new warnings with <limits>

David Leimbach leimy2k at mac.com
Sun Jul 13 11:25:58 PDT 2003


On Sunday, July 13, 2003, at 1:11PM, M. Warner Losh wrote:

> In message: <20030713152154.GA96653 at stack.nl>
>             Jilles Tjoelker <jilles at stack.nl> writes:
> : The compiler moans about (T)(-1) >=3D 0 as well. Is the assumption =
that
> : (unsigned type)(-1) is never zero valid?
>
> yes.  There are no known machines where -1 =3D=3D 0 for types of =
different
> signs.  Further, the C standard says that it must behave as if it is a
> two's complement machine, and I think that C++ says so too.
>

I am pretty certain you can do one's compliment in the C99 standard,=20
and that
some of that is implementation/platform dependant.

See section 6.2.6.2 of the C99 standard which enumerates the following 3
negative number representations:

=A1Xthe corresponding value with sign bit 0 is negated (sign and=20
magnitude);
=A1Xthe sign bit has the value-(2^N )(two=A1=A6s complement);
=A1Xthe sign bit has the value-(2^N -1) (one=A1=A6s complement).

further:
"Which of these applies is implementation-defined, as is whether the=20
value with sign bit 1 and all value bits zero (for the first two), or=20
with sign bit and all value bits 1 (for one=A1=A6s complement), is a =
trap=20
representation or a normal value. Inthe case of sign and magnitude and=20=

one=A1=A6scomplement, if this representation is a normal value it is =
called=20
a negative zero. "

Yes... a negative 0.


> Warner
> _______________________________________________
> freebsd-current at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-current
> To unsubscribe, send any mail to=20
> "freebsd-current-unsubscribe at freebsd.org"



More information about the freebsd-current mailing list