In article ,
dalloff@gcfn.org (Dave Althoff Jr) wrote:
> Just a simple one...
>
> When we refer to a hexadecimal number, we designate it like this:
>
> $FB6F
>
> When anybody else does it, they do it like this:
>
> 0xFB6F
>
> I don't know about you, but I find that really confusing. Someone sent me
> a look-up table for an I/O routine and it took me the longest time to
> figure out what it meant because of all that 0x crap in there.
>
> (I have no formal training on any other system. I was taught some Applesoft
> and some 6502, everything else I know is self-taught)
>
> Now we've been around a lot longer than most of those other programming
> systems...what in the world possessed them not to use the $ standard that
> we established decades ago?? Am I missing something important here? 8-)
>
> --Dave Althoff, ][.
Yes, you are. The $ is a convention used by Apple programmers. A much
more common notation for hex digits in assembly language on other
platforms is an 'h' (or 'H') suffix, as in FB6Fh or FB6FH, which is also
by convention.
The 0x notation is in fact part of ANSI X3.159-1989 (and the equivalent
ISO) standard for the C programming language. To quote from X3.159-1989:
3.1.3.2 Integer Constants
Syntax
Description
A decimal constant begins with a nonzero digit and consists of a
sequence of decimal digits. An octal constant consists of the prefix 0
optionally followed by a sequence of the digits 0 through 7 only. A
hexadecimal constant consists of the prefix 0x or 0X followed by a
sequence of the decimal digits and the letters a (or A) through f (or F)
with values 10 through 15 respectively.
Jalapeno wrote:
>In article ,
> dalloff@gcfn.org (Dave Althoff Jr) wrote:
>
>> Just a simple one...
>>
>> When we refer to a hexadecimal number, we designate it like this:
>>
>> $FB6F
>>
>> When anybody else does it, they do it like this:
>>
>> 0xFB6F
>>
>> I don't know about you, but I find that really confusing. Someone sent me
>> a look-up table for an I/O routine and it took me the longest time to
>> figure out what it meant because of all that 0x crap in there.
>>
>> (I have no formal training on any other system. I was taught some
>Applesoft
>> and some 6502, everything else I know is self-taught)
>>
>> Now we've been around a lot longer than most of those other programming
>> systems...what in the world possessed them not to use the $ standard that
>> we established decades ago?? Am I missing something important here? 8-)
>>
>> --Dave Althoff, ][.
>
>Yes, you are. The $ is a convention used by Apple programmers. A much
>more common notation for hex digits in assembly language on other
>platforms is an 'h' (or 'H') suffix, as in FB6Fh or FB6FH, which is also
>by convention.
>
>The 0x notation is in fact part of ANSI X3.159-1989 (and the equivalent
>ISO) standard for the C programming language. To quote from X3.159-1989:
>
>3.1.3.2 Integer Constants
>
>Syntax
>
>
>Description
>
>
>A decimal constant begins with a nonzero digit and consists of a
>sequence of decimal digits. An octal constant consists of the prefix 0
>optionally followed by a sequence of the digits 0 through 7 only. A
>hexadecimal constant consists of the prefix 0x or 0X followed by a
>sequence of the decimal digits and the letters a (or A) through f (or F)
>with values 10 through 15 respectively.
Standards are merely conventions that have "hardened". ;-)
Most number representation conventions are just scanner hacks, like
the "$" and the C convention. A prefix is clearly easier to deal with
lexically, since the modulus of conversion is known before the significant
digits are scanned.
The "h" suffix convention is more difficult, since, in general, it is detected
after part of the number has been converted as a decimal number, and
the scanner must backtrack and re-convert. A scanner writer would never
choose such a notation--but a microprocessor designer might. ;-)
The convention chosen for C is a bit of frozen history. The PDP-11
on which it was written used octal as its normal M/L convention, so
octal and decimal were the first things to be supported, and adding a
leading zero to octal constants seemed easy enough--everything else
was decimal. Then it became clear that a prefix extension for binary
and hex would be needed, and the code for it was grafted into the
octal path, as a non-octal digit following the leading zero: b for binary
and x for hexadecimal. Pure hack--no clear generalization to other
radices--but sufficient for all practical purposes, and now frozen into
the standard forever. It's a shame that hex (and binary, for that matter)
didn't get the first-class, single-prefix-character treatment that octal
gets, but that's history for you. ;-)
(BTW, hex digits were not always 0-9 + A-F. Early in the history
of computing, the Librascope LGP-30 used hex notation (because
its words were a multiple of 4 bits) and chose 0-9 + p-u! It didn't
catch on. ;-)
-michael
Check out amazing quality sound for 8-bit Apples on my
Home page: http://members.aol.com/MJMahon/
"Michael J. Mahon" wrote:
>
> [snip...] [snip...] [snip...]
>
> (BTW, hex digits were not always 0-9 + A-F. Early in the history
> of computing, the Librascope LGP-30 used hex notation (because
> its words were a multiple of 4 bits) and chose 0-9 + p-u! It didn't
> catch on. ;-)
>
Also, the MISTIC system at Michigan State University in
the 1950's used KSNJFL for the digits 11 through 15. This
was because these were the five-digit character codes for
these letters. The MISTIC system was a copy of the Illiac.
--
+----------------------------------------------------------------+
| Charles and Francis Richmond richmond at plano dot net |
+----------------------------------------------------------------+
In Scott Alfter wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> In article ,
> Dave Althoff Jr wrote:
>>Just a simple one...
>>
>>When we refer to a hexadecimal number, we designate it like this:
>>
>>$FB6F
>>
>>When anybody else does it, they do it like this:
>>
>>0xFB6F
>
> That's C notation, which started on UN*X and spread elsewhere from
> there... anybody who's written stuff in C or C++ will be familiar with
> that. The TI-99/4(A) folks have yet another notation they use...">"
> instead of "$" or "0x", IIRC. I wouldn't be surprised if there are
> other forms used by Atari, Commodore, and other 8-bit machines.
Some other systems used the dollar sign, probably copied from Apple or
from the same source Apple adopted their convention from. IIRC, BBC
Micro and MS QBasic use an ampersand prefix for hexadecimal e.g. &FB6F.
The 0x notation always seems wasteful to me since it requires TWO
characters to convey one bit of information. It would make sense if used
for other number bases though e.g. Bx10001001, Ox25, HxFB6F, Dx65535.
--
Roger Johnstone, Invercargill, New Zealand
PS/2 Mouse Adapter for vintage Apple II or Mac
order at http://vintageware.orcon.net.nz