Re: negative hex



On Jun 29, 11:38 am, John Larkin
<jjlar...@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
On Sun, 29 Jun 2008 14:09:41 +0800, rebel <m...@xxxxxxxxxxx> wrote:
On Sat, 28 Jun 2008 11:23:18 -0700, John Larkin
<jjlar...@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

I would like to say first that John (Larkin) has a zero-defect
understanding of his numbering systems, to all those who have offered
there thoughts. He is not confused in the least. :) The answer his
question is not so much and answer about numbering system, but more of
a "Where is the restroom?" question.

The answer is that, traditionally, no syntax has been prescribed for
expressing negative constants when the base is 16. This has been true
for most, if not all, of the popular modern languages including C/C++.

As he noted, there is nothing that would have prevented the language
designer from taking the exact same approach to base 16 as any other
base. One could even arge that a regular language might have allowed
any base between two reasonable values, say 2 and 36, with appropriate
encoding and an explicit negative or positive sign affixed at left.

-Le Chaud Lapin-
.



Relevant Pages

  • Re: Negations
    ... Ron Hardin wrote: ... bullet wounds in them,'' one of the doctors on the scene told CNN. ... unnegating both clauses and taking it as a negation of the original ... self styled arbiter of the English language around here! ...
    (sci.lang)
  • Re: Complete and decidable arithmetic / complete but undecidable arithmetic
    ... What does "complete" mean in absence of negation? ... all true statements in some language -- take for example the language ... theorists -- e.g. statements to the effect a Diophantine equation has or ... has no solutions -- no formal theory that satisfies a minimal soundness ...
    (sci.logic)
  • Re: "dictionary" vs. "hotel"
    ... AFAIK Yiddish has always had negative associations in Israel. ... Basically, it is the language of the ghetto and the shtetl, i.e. the ... dragged into a gas chamber without putting up a fight. ... negation of the "Yiddish" kind of Jewishness, ...
    (sci.lang)
  • Re: N00b question on let
    ... But if you had this unary minus read macro, you would just use it like ... numeric symbols have support for negation built into them. ... should the printed representation of a negative number be? ... if that language were opened up to its programs as a data ...
    (comp.lang.lisp)
  • 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)