James Kuyper <(E-Mail Removed)> wrote:

> On 03/19/2013 10:49 AM, Noob wrote:
(snip)

>> Considering a properly initialized unsigned int variable v,

>> are -v and ~(v-1) equivalent for any value of v, even on

>> the DS9k?
(snip)

>> I think this is true always, I don't think the "usual arithmetic

>> conversions" come in play in problematic ways?

> Since v is unsigned int, and 1 has the type int, the usual arithmetic

> conversions require that 1 be converted to unsigned int, and then

> everything goes through fine.

> The tricky case is an unsigned type where TYPE_MAX < INT_MAX, and v==0.

> In that case, the unsigned value is converted to int, so the result is

> ~(-1), which has different results depending upon whether 2's

> complement, 1's complement, or sign-magnitude representation is used.
Other than the DS9K, the sign-magnitude machines that I know about

are word addressed. They might not have any type smaller than int.

The last one I know about is the 7094, successor to the 7090 and 709.

With IBM OSs, they used six BCDIC (IBM called it BCD) characters

per 36 bit word. As I understand it, the card reader reads each

card punch row into two 36 bit words. Software then converts that

to six characters per word. Note that the last eight card colunmns

aren't read. (Possibly that was the 704, and not the 709. It is,

at least, the reason Fortran ignores columns 73-80 (in fixed-form).

Nine track tape drives didn't come along until later. Seven track

drives, six plus (even or odd) parity were used. So, what would

CHAR_BIT be on the 7094?

For ones complement, there are the CDC machines (10 six bit characters

in a 60 bit word) and Unisys machines, but popular long after the 7090.

> The DS9k, of course, only uses 2's complement representation in it's

> floating point implementation.
In PDP-10 style (2's complement the whole word) or DSP style

(significand only)?

The PDP-10 allows one to use integer compare instructions on floating

point values (and get the right result). Somewhat convenient for

sorting, such that you don't need to know which fields are integer

and which aren't.

Seems to me that C pretty much requires binary for integer types,

but, for example, IEEE 754-2008 style decimal float should work

(which is sign magnitude). But a nine's complement or ten's

complement decimal float form should also work.

-- glen