🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c.moderated
Article #2015

Re: Why Use 'Int' Instead of 'Long'? (With today's compilers)

#2015
From: Steven Huang
Date: Fri, 16 Feb 1996 06:12
30 lines
1907 bytes
In article <4fu7tj$9a1@solutions.solon.com> als@fl.net.au (Andrew Snow) writes:
>wawda@chaph.usc.edu (Abu Wawda) wrote:

>>I am curious why one would use int instead of long with many of the
>>compilers today.
[snip]

>If you explicetly wanted a 16 bit data variable, you would use a
>"short int".  If you explicetly wanted a 32 bit variable, you would
>use "long int".  If you didn't mind, and were prepared to use either
>16-bit or 32-bit, whichever the particular operating system you are
>compiling for decided was best, then you just use "int".

>To make your code completely portable, you should specify long or
>short.  In situations where it really doesn't matter, you can just
>use "int".

You're way off track as well.  Short or long has nothing to do with
the size of the integer in terms of bits.  You will never be guaranteed
a certain number of bits you can use.  If I remember correctly the
only guarantee you have is that short is less than or equal to int,
and int is less than or equal to long.  The reason for using int is
because int is generally mapped to the most efficient computation the
CPU can handle.  You would use long or short if you need more capacity
(not that more is guaranteed) or wish to save some space because you
don't need so much capacity, respectively.

-- 
Steven Huang (sthuang@hns.com)  Hughes Network Systems
Opinions stated herein are my own.
Technical Details
Message-ID: <4g1793$muh@solutions.solon.com>
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
References: <4fjk00$nss@solutions.solon.com> <4fu7tj$9a1@solutions.solon.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
From: sthuang@hns.com (Steven Huang)
Newsgroups: comp.lang.c.moderated
Subject: Re: Why Use 'Int' Instead of 'Long'? (With today's compilers)
Date: 16 Feb 1996 00:12:51 -0600
Organization: Hughes Network Systems Inc.
Sender: clc@solutions.solon.com
Approved: clc@solutions.solon.com
Message-ID: <4g1793$muh@solutions.solon.com>
References: <4fjk00$nss@solutions.solon.com> <4fu7tj$9a1@solutions.solon.com>
NNTP-Posting-Host: solutions.solon.com