Re: negative hex



On Mon, 30 Jun 2008 20:28:49 -0700, JosephKK <quiettechblue@xxxxxxxxx>
wrote:

On Sun, 29 Jun 2008 09:38:05 -0700, John Larkin
<jjlarkin@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

On Sun, 29 Jun 2008 14:09:41 +0800, rebel <me@xxxxxxxxxxx> wrote:

On Sat, 28 Jun 2008 11:23:18 -0700, John Larkin
<jjlarkin@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

Microprocessors don't make value judgements about bits in registers;
only people do that. 0xFEEE is just a pattern of bits; whether it's
positive or negative is up to you.

John, I've been sitting on the side wondering whether to put in 2c worth, and
this seems like it is the time and place.

Surely it can't be "negative" if it is a pattern of bits. The bits are 0 or 1.
Not a negative option in sight.

I'm asking about how one would *express* a number which results from
the negation of an integer which is itself expressed in hex. A true
integer is a point on the infinite number line. In decimal, "256"
names one of those points in decimal; if we agree on the syntax, 0x100
names that same point in rad16.

Decimal -256 names a different point, one on the opposite side of the
origin from 256. So how should we agree to name that point in hex? I
think we agree that -0x100 is good.

Once we start to cram pure-mathematical integers into finite-length
binary registers, it gets a bit more complicated. It's still simple as
long as we agree on a naming convention for signed values (and 2's
complement is almost always the choice) and we don't overflow the
number of available bits. In 2's complement, if the most significant
bit of the register is set, we call the number negative.

8-bit wide, 2's complement convention:

0 0 0 0 0 0 0 0 = decimal 0
0 0 0 0 0 0 0 1 = decimal 1
0 0 0 0 0 0 1 1 = decimal 3
0 1 1 1 1 1 1 1 = decimal 127
1 0 0 0 0 0 0 0 = decimal -128
1 1 1 1 1 1 1 1 = decimal -1

John


There is good reason for that as well; it is the only system that
leverages the existing ALU to the max for doing multiple byte /
halfword / word / double-word and wider in a consistent manner.

And you claimed to not understand hex regrouping of 2's compliment.

Now I am confused. What is it that I claimed to not understand?

John

.



Relevant Pages

  • Re: negative hex
    ... John, I've been sitting on the side wondering whether to put in 2c worth, and ... Surely it can't be "negative" if it is a pattern of bits. ... the negation of an integer which is itself expressed in hex. ... In 2's complement, if the most significant ...
    (sci.electronics.design)
  • Re: negative hex
    ... John, I've been sitting on the side wondering whether to put in 2c worth, and ... Surely it can't be "negative" if it is a pattern of bits. ... the negation of an integer which is itself expressed in hex. ... In 2's complement, if the most significant ...
    (sci.electronics.design)
  • Re: Twos Complement, Serialization, etc.
    ... I believe the direct assignment to the unsigned variable in pack16() ... line 3 should give us the two's complement negative by C99-6.3.1.3p2. ... `int' that's in range for an `int16_t'. ... 0x8000u, this is unchanged by negation, and now you try to convert ...
    (comp.lang.c)
  • Re: Query: Classical conjugation pattern.
    ... 286, under the entry for `zu' (which expresses negation), here is ... A single form, ZU, conjugates independently in ... conjugation moved in a single column through the six bases, ... pattern that is otherwise established. ...
    (sci.lang.japan)
  • Re: string search for 0 and/or 1
    ... pattern would not reject an empty line. ... and it is common to consider an empty string/line as a possible ... This is the actual negation of my expression. ... negative match. ...
    (comp.lang.tcl)