[LCP]struct & union
Paul Gearon
pag at PISoftware.com
Mon Feb 4 17:17:37 UTC 2002
On Mon, 4 Feb 2002, shahnavaz wrote:
> hi,
> I think that has solved my doubt.But can you tell me why is int and float
> have same size then(ofcourse on linux i386).
The size of a float is part of the standard. If you check out the
"reading" section of the gcc site it says that gcc is s based on C99.
The C99 standard says that it extends C89, and the C89 Rational document
says:
"Single precision (32-bit) floating point is considered adequate to
support a conforming C implementation."
http://www.lysator.liu.se/c/rat/b.html#2-2-4-2-2
Note that it doesn't *have* to be 4 bytes, but it is anyway.
(now for the part I don't really know)
ints are similar. From memory, ints used to conform to the default word
size of the machine - though I may be wrong here. People started to
standardize on the size of the int by the time 32bit architectures come
in. For example, when M$ went from win16 to win32 they changed ints from
16 bit to 32 bit. However, now that win64 is available I think M$ left
the size of an int at 32 bits so as not to break too many existing
applications.
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.
Regards,
Paul Gearon
Software Engineer Telephone: +61 7 3876 2188
Plugged In Software Fax: +61 7 3876 4899
http://www.PIsoftware.com PGP Key available via finger
Catapultam habeo. Nisi pecuniam omnem mihi dabis, ad caput tuum saxum
immane mittam.
(Translation from latin: "I have a catapult. Give me all the money,
or I will fling an enormous rock at your head.")
More information about the linuxCprogramming
mailing list