Tuesday, July 28, 2009

In C language when we check the size of int data type-it gives 4 for float also it gives 4 .why ?

i am working in C in linux,gcc compiler i am using.

In C language when we check the size of int data type-it gives 4 for float also it gives 4 .why ?
Because those are the default sizes.
Reply:.





It depends on the type of OS you use and the type of Compiler you use.





In Turbo C, integers will be given size 2 and floats size will be 4.





But in linux gcc compiler, both of them have size 4 bytes.





Its all how the compiler considers the variables to be.





**********


Vasu M


**********
Reply:In Turbo C, integers will be given size 2 and floats size will be 4.





But in linux gcc compiler, both of them have size 4 bytes.
Reply:Both are 4-byte values, with different ways of encoding the underlying number. Int's commonly allow +/- 2^31 (roughly +/- 2,000,000,000) and floats allow for roughly 7 places of accuracy.


No comments:

Post a Comment