How To Calculate Range of Data Types in C

Status
Not open for further replies.

krishnandu.sarkar

Simply a DIGITian
Staff member
Hiiiiiiiiiiiiiii.............Can any1 tell me d process to calculate range of data types in c????

I mean INT allocates 2 bytes in memory...........n itz range in 16 bit compilor is frm -37628 to +37627.............now how these is calculated?????...................
 

ThinkFree

Technomancer
Its -32768 to +32767
2 raised to power 16(16 bit sys)=65536, so it can have 65536 different integer values (32768+32767+1 for 0 =65536). Similarly for 32 bit, 2 raised to power 32 values can be there for integers
 

blueshift

Wise Old Crow
The range values are defined in limits.h header file.
For displaying the range of INT data type, you can print the value of INT_MAX and INT_MIN macros defined in that header file.
 
Status
Not open for further replies.
Top Bottom