Date: Sun, 13 Jul 2003 13:25:45 -0500 From: David Leimbach <leimy2k@mac.com> To: "M. Warner Losh" <imp@bsdimp.com> Cc: jilles@stack.nl Subject: Re: GCC 3.3.1, new warnings with <limits> Message-ID: <6B36552C-B55F-11D7-BE3B-0003937E39E0@mac.com> In-Reply-To: <20030713.121125.54936166.imp@bsdimp.com> References: <20030713000559.28c18be6.kabaev@mail.ru> <20030713044331.GA89785@crodrigues.org> <20030713152154.GA96653@stack.nl> <20030713.121125.54936166.imp@bsdimp.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sunday, July 13, 2003, at 1:11PM, M. Warner Losh wrote: > In message: <20030713152154.GA96653@stack.nl> > Jilles Tjoelker <jilles@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@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-current > To unsubscribe, send any mail to=20 > "freebsd-current-unsubscribe@freebsd.org"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6B36552C-B55F-11D7-BE3B-0003937E39E0>