www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/16/08:32:47

From: ao950 AT FreeNet DOT Carleton DOT CA (Paul Derbyshire)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Weird problem
Date: 16 Mar 1997 11:30:44 GMT
Organization: The National Capital FreeNet
Lines: 32
Message-ID: <5ggll4$6pb@freenet-news.carleton.ca>
References: <33287185 DOT 892303 AT news DOT flash DOT net> <33287D83 DOT 63AD AT shoreland DOT com> <332aa0d0 DOT 1431214 AT ursa DOT smsu DOT edu>
Reply-To: ao950 AT FreeNet DOT Carleton DOT CA (Paul Derbyshire)
NNTP-Posting-Host: freenet5.carleton.ca
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019