Floats and Doubles in C

A float occupies four bytes in memory and can range from -3.4e38 to +3.4e38. If this is insufficient then C offers a double data type that occupies 8 bytes in memory and has a range from -1.7e308 to +1.7e308. A variable of type double can be declared as

double a, population ;

If the situation demands usage of real numbers that lie even beyond the range offered by double data type, then there exists a long double that can range from -1.7e4932 to +1.7e4932. A long double occupies 10 bytes in memory

Table of All data types in C

Data TypeRangeBytesFormat
signed char-128 to + 1271%c
unsigned char0 to 2551%c
short signed int-32768 to +327672%d
short unsigned int0 to 655352%u
signed int-32768 to +327672%d
unsigned int0 to 655352%u
long signed int-2147483648 to +21474836474%ld
long unsigned int0 to 42949672954%lu
float-3.4e38 to +3.4e384%f
double-1.7e308 to +1.7e3088%lf
long double-1.7e4932 to +1.7e493210%Lf
Table of All data types in C

Leave a Comment