A
alok
Why bytes needed by int and float is machine dependent?
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).
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.
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.