[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[csmith-bugs] Fwd: Re: negative zero and two's complement
Another opinion below. Derek has served on the C standards committee so
I tend to take his views seriously.
-------- Original Message --------
Subject: Re: negative zero and two's complement
Date: Fri, 27 Jun 2014 19:46:41 +0100
From: Derek M Jones <firstname.lastname@example.org>
Organization: Knowledge Software, Ltd
To: John Regehr <email@example.com>
Hi Derek, someone on the csmith-bugs mailing list claims that for a C
implementation that uses two's complement, ~INT_MAX is undefined
behavior by 188.8.131.52:4.
as might be: (-2) & (-1)
The counterargument would be that a two's complement implementation has
no negative zero this rule does not apply.
"If the implementation does not support negative zeros, ..."
One's complement does support negative integers and by
implication two's complement and sign magnitude might not (since
they are not required to).
"... that would produce such a value..."
All the bit patterns are 'filled up' with values in two's
complement, so no way to get a negative zero.
That just leaves sign magnitude. Which may or may not
support signed zero
Do you have an opinion on this matter?
Life would be more interesting if sign magnitude machines
were used from time to time.
Derek M. Jones tel: +44 (0) 1252 520 667
Knowledge Software Ltd blog:shape-of-code.coding-guidelines.com
Software analysis http://www.knosof.co.uk