[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cross-platform programming question...



In article <bnesff$b90$1@acme.gcfn.org>,
 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
<snip>

Description

<snip>
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.