Re: shame on MISRA



CBFalconer wrote:
Arlet wrote:

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

<snip>

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.

Seymour Cray's Control Data machines employed subtractors (there
were of course ISAs designed by others at CDC); I found 2's complement
arithmetic alien after having been immersed in the CDC 1's complement
universe for so long. On the 160/8090 series (or the 6000/7000 PPU),
6000 series and 7000 series, '-0' is never generated by
arithmetic but only by manipulation.

Regards,

Michael
.



Relevant Pages

  • Re: shame on MISRA
    ... at least one argument is already negative zero, ... manipulating the bits. ... Seymour Cray's Control Data machines employed subtractors (there ... were of course ISAs designed by others at CDC); I found 2's complement ...
    (comp.arch.embedded)
  • Re: Primitive Type Sizes
    ... > It's hard for me to remember now but I think in one's complement ... > negative zero, so I think java supports negative zero. ... > I do not think negative zero is possible with two's compliment integers. ... Seymore Cray worked at CDC prior to ...
    (comp.lang.java)
  • Re: How to extract bytes from long?
    ... > ~0 is negative zero in ones complement. ... > Implementations are allowed trap negative zero. ... If the promoted type is an unsigned type, ...
    (comp.lang.c)
  • Re: What does this mean???
    ... Not on a 1's complement or a signed magnitude machine. ... Who says i is declared as int? ... If negative zero is supported, ...
    (comp.lang.c)
  • Re: Primitive Type Sizes
    ... >>negative zero, so I think java supports negative zero. ... >>I do not think negative zero is possible with two's compliment integers. ... Seymore Cray worked at CDC prior to ... > his lesson and it was two's complement. ...
    (comp.lang.java)