[LCP]struct & union
Greg Black
gjb at gbch.net
Mon Feb 4 17:39:13 UTC 2002
Paul Gearon wrote:
| The size of a float is part of the standard.
Only in part. The C89 standard defines the minimum sizes of all
types, but puts very few limits on maximum sizes. The important
detail is that these things are "implementation-defined" and the
Standard says that the limits must be defined in the standard
headers <limits.h> and <float.h>. The minimum sizes are in
Section 5.2.4.2 "Numerical limits" in ISO 9899: 1990 (aka C89).
| The C99 standard says that it extends C89, and the C89 Rational document
| says:
Note that the "Rationale" is not itself part of the Standard and
nothing in it is binding.
| Someone here may have a more accurate picture of what size an int is in a
| given circumstance. These days I just accept that it's 32 bits since
| everyone seems to have standardized on that size.
Not at all. People running 16-bit or smaller CPUs will almost
certainly be using 16-bit "int". People with big registers may
well use 64-bit or 128-bit sizes for "int". Of course, as so
many people discovered when 64-bit CPUs started to be used more
widely, lots of software is written by people who just don't
understand C's size rules and who write software that breaks in
the face of "unexpected" sizes of "int", "long", etc.
A good C programmer learns how this works and keeps it in mind
when writing code.
Greg
More information about the linuxCprogramming
mailing list