Re: I long for an int
Valentin Samko wrote:
Victor Bazarov wrote:
It all comes down to what your model (world) is like. From
the C++ point of view, when you say 'int', you really mean
"no more than 32767" because that's the lower limit.
There is no such "lower limit" for int in C++. int may have
the same size as char.
In which case, char must be at least 16 bits. The language
specifications guarantee that INT_MAX >= 32767.
In practice, of course, not all code is, or needs to be,
designed to run on all possible configurations. In the code I
write, I regularly suppose that an int will be at least 32 bits,
for example -- I work on large server software, and no 16 bit
machine would ever have the necessary performance anyway (and if
I use long, I'll end up with 64 bits, which will reduce locality
and cause the application to run slower). The important thing
is to decide your assumtions up front, before starting, and to
document them.
--
James Kanze GABI Software
Conseils en informatique orient?e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S?mard, 78210 St.-Cyr-l'?cole, France, +33 (0)1 30 23 00 34
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]