Re: shame on MISRA



Arlet wrote:
On Apr 28, 2:24 am, Dan Henry <use...@xxxxxxxxxxxxx> wrote:

Are you saying that in 1's complement the integer constant 0 could
have the bit pattern for +0 (all 0's) *or* the bit pattern for -0
(all 1's) and that using the unary - operator on the integer
constant 0 can yield either all 1's or all 0's -- that my
memset(&object, 0, sizeof object) is equally likely to zero all
bits as set all bits of the memory that object occupies?

No, negative zero can not be produced by a literal constant, like
'0'. Negative zero can only be the result of some expressions where
at least one argument is already negative zero, or by directly
manipulating the bits.

This is wrong. It depends on how the adders are configured. The
obvious method of subtracting by complementing and adding can
generate negative 0. The presence of a negative 0 can force such
an output. In fact, the means of avoiding negative zero is to use
a subtractor, rather than an adder, and prevent the injection of
any negative zero.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
<http://kadaitcha.cx/vista/dogsbreakfast/index.html>
cbfalconer at maineline dot net



--
Posted via a free Usenet account from http://www.teranews.com

.