Re: negative hex
- From: Le Chaud Lapin <jaibuduvin@xxxxxxxxx>
- Date: Sun, 29 Jun 2008 10:46:28 -0700 (PDT)
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-
.
- Follow-Ups:
- Re: negative hex
- From: Frank Buss
- Re: negative hex
- References:
- negative hex
- From: John Larkin
- Re: negative hex
- From: Tim Wescott
- Re: negative hex
- From: John Larkin
- Re: negative hex
- From: rebel
- Re: negative hex
- From: John Larkin
- negative hex
- Prev by Date: Re: Intel rejects Vista, will stay with XP and wait for windows7
- Next by Date: Re: negative hex
- Previous by thread: Re: negative hex
- Next by thread: Re: negative hex
- Index(es):
Relevant Pages
|