Why can't I xor strings?
Grant Edwards
grante at visi.com
Mon Oct 11 15:35:55 EDT 2004
On 2004-10-11, Jeremy Bowers <jerf at jerf.org> wrote:
>>> With respect, this isn't something to doubt or not doubt.
>>> There is one, and only one, way to represent any positive
>>> number in base two, since encoding sign is not an issue.
>>> Assuming an extra bit to show sign, there is one and only one
>>> way to represent any negative number, too.
>>
>> That's news to me. I've used three different base-2
>> representations for negative numbers in the past week, and I
>> can think of at least one other one I've used in the past.
>
> I am aware of only one encoding that uses a single bit to
> represent sign, as I stipulated, and discarding endianness
> issues I'm having a hard time imagining what reasonable
> alternatives there are.
* Two's compliment.
* One's compliment.
* Signed-magnitude with a "1" sign bit being positive.
* Signed-magnitude with a "1" sign bit being negative.
* Excess-N notation.
Four of the five are in use in the software I'm working on
today.
>>> (Zero gets to be the exception since then you can have
>>> positive and negative zero,
>>
>> That depends on which base-2 representation you've chosen. In
>> two's compiliment and excess-N representations, there is only
>> one zero value. In signed-magnitude there may be two.
>
> I explicitly only discussed signed-magnitude: "Assuming an
> extra bit to show sign".
I don't know what you mean. Two's compliment, one's
compliment, signed-magnitude, and excess-N _all_ use a single
bit for sign.
--
Grant Edwards grante Yow! Kids, don't gross me
at off... "Adventures with
visi.com MENTAL HYGIENE" can be
carried too FAR!
More information about the Python-list
mailing list