Subject: Re: long long vs long
From: [email-masked] (sjm)

23 Jul 1998 20:17:30 -0700
Message-ID: <9807231347.AA10987.cygnus.gnu-win32@frodo>
To: gw32 <[email-masked]>

Earnie Boyd writes:
 > Or why not set a new standard something like
 > 
 > int8, int16, int32, int64 to indicate the number of bits.

Right! The ambiguity of variable sizes has been the most unportable feature of
C. I know why they did it but it is still a pain. In those days the world
hadn't decided whether word sizes would be a multiple of 6 or 8 bits.
Implementing a 32 bit data type on an 18 bit (or 24 bit) machine would have
been a disaster. Some machines would have wanted int6, int12, int18 and int24
as bacic integer sizes. It was better to leave word sizes ambiguous and accept
the portability problem.

Did you ever wonder why octal was so popular and why many C constants were
originally only defineable as octal? Octal makes sense in an environment with
word sizes of multiples of 3 bits. Hex is only useful with multiples of 4
bits.

For those who don't remember, early DEC and IBM machines were 6 bit based. For
example the PDP-8 has a 12 bit word size. The IBM 360 was 36 bits. Radix 6
character encoding was quit popular on such machines.

Even worse, many processors only supported one word size. For example special
code needed to be emitted to access bytes on the 16 bit Nova machines. There
were no byte instructions; a lot of shifting and masking. That is what "int"
was for. It was intended to be the native "fast" data type that could be
accessed with single instructions. On a 16 bit machine a 32 bit word was
accessed as two words and implemented as multiple word arithmetic. Of course
that is how "long long" is implemented on most machines today.

Now that bytes have become a defacto standard for word size multiple and
variable word size inctructions exist everywhere one would think C could move
forward. Then again maybe intel is going to jump from variable 64 to a fixed
96 bits for the p96 generation.

Steve Morris
[email-masked]
-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".