In message: <6B36552C-B55F-11D7-BE3B-0003937E39E0_at_mac.com> David Leimbach <leimy2k_at_mac.com> writes: : : 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) >= 0 as well. Is the assumption that : > : (unsigned type)(-1) is never zero valid? : > : > yes. There are no known machines where -1 == 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, : 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: : : ¡Xthe corresponding value with sign bit 0 is negated (sign and : magnitude); : ¡Xthe sign bit has the value-(2^N )(two¡¦s complement); : ¡Xthe sign bit has the value-(2^N -1) (one¡¦s complement). : I'm aware of that. However, the section that I quoted in my other mail (assuming it went out) says that when converting from signed to unsigned must be done in a way as if it was two's complement. : further: : "Which of these applies is implementation-defined, as is whether the : value with sign bit 1 and all value bits zero (for the first two), or : with sign bit and all value bits 1 (for one¡¦s complement), is a trap : representation or a normal value. Inthe case of sign and magnitude and : one¡¦scomplement, if this representation is a normal value it is called : a negative zero. " : : Yes... a negative 0. Yes. that's true, but never with unsigned types. Again, the standard specifies math such that you must make things behave as if it is two's complement, even if it isn't represented like that in the underlying bits. WarnerReceived on Sun Jul 13 2003 - 10:46:08 UTC
This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:15 UTC