Mail Archives: djgpp/1997/03/16/08:32:47
Tony O'Bryan (aho450s AT nic DOT smsu DOT edu) writes:
> On Thu, 13 Mar 1997 16:19:47 -0600, Ray Ratelis <ray AT shoreland DOT com> wrote:
>
>>It is because in Turbo C++, ints are 2 bytes in size. (int = 16bit,
>>short int = 8bit(?))
>>In PM, and any other 32bit OS, ints are 4 bytes in size. (int = 32bit =
>>long int, short int = 16bit)
>
> I believe that shorts are always guaranteed to be 16 bits, regardless of the
> system. Last I heard (I have never actually had access to the ANSI specs, and
> had to learn everything through experience and word-of-mouth) integers take on
> the size of the machine word of the computer compiling the program (hence 16-bit
> DOS has 16-bit integers and GCC has 32-bit integers). That is why the use of
> ints hinders portability and the use of shorts and longs are preferred when
> numbers need to be in specific ranges supported by those datatypes.
>
> As usual, I am happy to receive insights that reduce my ignorance. :) Please
> correct me if I am wrong.
But, an article on optimization informed me that using a 32-bit compiler
like DJGPP, if you use shorts and such it adds a whole extra instruction
for every operation in registers on the value in question, and that to
speed up code use "int" instead. So I guess portability and optimization
are sometimes exclusive?
--
.*. Where feelings are concerned, answers are rarely simple [GeneDeWeese]
-() < When I go to the theater, I always go straight to the "bag and mix"
`*' bulk candy section...because variety is the spice of life... [me]
Paul Derbyshire ao950 AT freenet DOT carleton DOT ca, http://chat.carleton.ca/~pderbysh
- Raw text -