Re: random_number



Gordon Sande wrote:
(snip)

There have been Fortrans on machines of other word sizes in the
past. 36 bits was "the standard" at one point in history. Some
machines even used sign magnitude (twos complement in other jargons)
for symmetric ranges.

This is  common confusion between "the compiler I use" and "the
standard". There have been several threads over how small the range of
integers could be and still meet the standard.

I am pretty sure that Fortran still allows other than 32 bits, and
twos complement, ones complement, or sign magnitude, and probably
even allows decimal (sign magnitude, nines complement or tens complement, or even more).


Historically, sign magnitude was used more, as it is more like
the way people do it on paper.  The IBM 704 is 36 bit sign magnitude.

Like sign magnitude, ones complement is also symmetric with positive and negative zero, but easier for doing addition and subtraction.
CDC made ones complement machines, and Univac still does.
A parallel adder is just about as easy to build in ones complement,
the difference is that the carry out from the MSB is used as a carry in to the LSB.


C still allows twos complement, ones complement and sign magnitude for signed arithmetic. Unsigned is unsigned. C does not allow decimal representation unless it is made to look like binary.

-- glen

.



Relevant Pages

  • Re: Fast sincos routine
    ... Of the legal integer representations, ones, twos ... >> complement, and sign magnitude, there is always a sign bit ...
    (comp.lang.c)
  • Re: sign magnitude, ones complement, twos complement
    ... >> two's complement ... >> What are the pitfalls of them? ... > I doubt if sign magnitude has ever been used in a popular US computer. ...
    (comp.lang.c)
  • Re: odd/even bitwise and
    ... >> It's also possible with Sign and Magnitude representation. ... > (The ones I know of are signed magnitude, one's complement, and two's ... You're not missing any representation methods allowed by the C ...
    (comp.lang.c)
  • Re: sign magnitude, ones complement, twos complement
    ... >> two's complement ... >> What are the pitfalls of them? ... > I doubt if sign magnitude has ever been used in a popular US computer. ... Multiply and divide are easier in sign magnitude, ...
    (comp.lang.c)
  • Re: [Lit.] Buffer overruns
    ... > should never alter sign), and so it's not just UB in the C standard, ... C allows twos complement, ... sign magnitude machines, though. ...
    (sci.crypt)