int and float memory space

A

alok

Because machines vary on the sizes of integers and floating point values
(and, for that matter, the size of a 'byte') that they work most efficiently
with.  For example, some smaller CPUs can work efficiently with 16 bit
values; anything larger than that is a pain.  On the other extreme, some
CPUs work most efficiently with 32 or 64 bit values, and convincing them to
work with smaller integers would actually slow things down.

Now, C could preselect a specific size (and insist that all implementations
do whatever conversion is necessary to make that specific size work);
however, C has a bias towards efficiency, and so it lets the implementation
pick what's efficient (as long as it meets various minimums, for example,a
variable of type 'int' must be able to represent any value between -32767
and 32767).

Poncho,

So if the machine size is 32 bit the integer size will be 32 bit?

thanks for your wonderful reply.
 
K

Keith Thompson

Scott Fluhrer said:
Perhaps, and perhaps not. That's really the compiler writer's call. The
intent in the design of C is that common C types be efficient, but there's
really nothing enforcing it.

And in practice, it's very common to choose sizes based on compatibility
with other systems. For example, if a 32-bit system is a direct
descendant of a similar 16-bit system, the implementer might well choose
to make int 16 bits so that code written for the older system will work
without change.
 

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,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top