size of an integer ??

M

Minti

Shalini said:
what does the size of an integer depend on ?? is it the Operating
system, processor or the associated memory in the system ??


Well primarily the size of the integer depends upon the processor itself
only. However processors do indeed have support for backward compatibility,
so you can see you code compiled by Turbo C++ 3.0 and other esoteric
compilers which have 16 bit integers execute quite easily on 32 bit
platforms and for that matter also on 64 bit platforms.
 
P

pete

Shalini said:
what does the size of an integer depend on ??
is it the Operating
system, processor or the associated memory in the system ??

I had a 16 bit compiler and a 32 bit compiler on the same machine.
 
S

Shalini

what does the size of an integer depend on ?? is it the Operating
system, processor or the associated memory in the system ??
 
J

James McIninch

The size of an integer is dependent on the whim of the author of the
compiler you use. While the CPU may have a notion of an "integer", the
compiler is not obliged to use it. You could have 43-byte integers on
hardware that used 32-bit arithematic and all it would mean is the compiler
writer did some tricky stuff behind the scenes to implement 43-byte ints.
 
K

Keith Thompson

Shalini said:
what does the size of an integer depend on ?? is it the Operating
system, processor or the associated memory in the system ??

It depends on the judgement of the implementer of the compiler,
subject to the restrictions in the standard. That judgement in turn
typically depends on the nature of the underlying system (int is very
often, but not always, the size of a CPU data register; sizes of other
integer types can depend on what the hardware conveniently supports).
Compatibility with other systems can also be a consideration; a
compiler for a "32-bit" system might have 16-bit int for compatibility
with older "16-bit" versions of the system. (I put "16-bit" and
"32-bit" in quotation marks because there's no universal agreement on
what those terms mean.)
 
M

Minti

Please don't top-post.




--
Imanpreet Singh Arora
If I would have only known, I would have been a locksmith.
-- Albert Einstein
 
J

Joona I Palaste

Minti said:
Please don't top-post.

Very funny.
--
Imanpreet Singh Arora
If I would have only known, I would have been a locksmith.
-- Albert Einstein

news:RqwXc.51671$9d6.18296@attbi_s54...

(snip)

--
/-- Joona Palaste ([email protected]) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"As a boy, I often dreamed of being a baseball, but now we must go forward, not
backward, upward, not forward, and always whirling, whirling towards freedom!"
- Kang
 
J

Jonathan Hoyle

what does the size of an integer depend on ?? is it the Operating
system, processor or the associated memory in the system ??

The compiler only. And even then it does not have to be fixed. For
example, in an earlier version of Metrowerks CodeWarrior C/C++, the
size of an int was a compiler preference setting.

Jonathan Hoyle
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,146
Messages
2,570,832
Members
47,374
Latest member
anuragag27

Latest Threads

Top