Loading ...
Sorry, an error occurred while loading the content.

Re: [ISO8601] ZERO has NO SIGNS

Expand Messages
  • Ed Davies
    ... I think there s some confusion here. Ones complement (as used on the CDC machines, IIRC) is to simply invert the bits (giving two representations of zero
    Message 1 of 4 , May 3, 2002
      bam wrote:

      > ....
      > In a twos-complement machine (such as the IBM 7040, my second computer),
      > negative numbers are indicated by complementing (0 becomes 1; 1 becomes 0)
      > every bit of the corresponding positive value. Thus, in a six-bit word
      > (or field), the bits representing ten and twelve would be 001010 and 001100
      > respectively, and bits representing -10 an -12 would be: 110101 and 110011
      > respectively. Unfortuantely, this leaves two bit configurations "between"
      > those for the signed numbers +1 and -1, i.e. 000000 and 111111.
      > ....
      > Ones-complement arithmetic (which I first saw on my third machine,
      > the CDC-6600) eliminates the degenerate representation between that for
      > zero and that for -1. In ones-complement hardware, the six-bit field
      > containing 111111 would represent -1 (not 0) and the numbers -10 and -12
      > would be 110110 and 110100 respectively.

      I think there's some confusion here.

      Ones complement (as used on the CDC machines, IIRC) is to simply invert
      the bits (giving two representations of zero (000000 and 111111)) whereas
      twos complement is to invert the bits then add one (000000 => 111111 =>
      000000, discarding the carry) so there is only one representation of
      zero. Most machines these days (e.g., those based on the Intel '86 family
      or the Motorola 68000 (I think - at least the 6800 did)) use twos complement
      for integer arithmetic though not necessarily for floating point.

      I've never used a 7040 but the first computer I used was its little brother,
      the 1130 which used twos complement arithmetic on 16 bit words. The FORTRAN
      IV manual for this machine had a good explanation of twos complement using
      a way of looking at the matter I have not seen described since. Instead of
      considering rather magic bit manipulations as above it pointed out that the
      the effect is that the weight of the top bit is -32768.

      To follow the examples above the weights on a six bit twos complement
      value would be:

      -32, 16, 8, 4, 2, 1

      so +5 = 000101. We get -5 by inverting to get 111010 then add one to
      get 111011 which is -32 + 16 + 8 + 2 + 1 = -32 + 27 = -5.

      Another way of looking at twos complement is that the top half of the number
      range is picked up and moved down below zero. So 111111 (-1) is followed by
      00000 (0) which seems reasonable.

      I don't want to get drawn into this debate about +/- year zero but couldn't
      let this misinformation on one and twos complement stand, however irrelevant.


      P.S., just to make sure it wasn't me spreading misinformation I double
      checked this by having a look in "The Art Of Electronics" by Paul
      Horowitz and Winfield Hill. On pages 476 and 477 (of my second
      edition) they describe two other representations we needn't go into
      here then under "2's complement representation" they say:

      > ....a negative number is simply represented as the binary number you
      > add to a positive number of the same magnitude to get zero. To form a
      > negative number, first complement each of the bits of the positive
      > number (i.e., write 1 for 0, and vice versa; this is called the "1's
      > complement"), then add 1 (that's the "2's complement").
      > ....
      > There's only one zero, conveniently represented by all bits 0....
    Your message has been successfully submitted and would be delivered to recipients shortly.