datatypes in c
The kind of data that a variable can hold is called datatype. The data may be numeric or non-numeric or any type .the storage of separate data types will differ from machine to machine (64 bit and 32bit)Integer
- Primary (fundamental) data types.
- Derived data type.
- User-defined data type
Primary data types
Int : int is used to assign integers to a variable but without a decimal point
Float: float is used to indicate a floating point number .float can contain integers with decimal points .float store maximum 6 digits after decimal number
Double: double is used to indicate double precision floating point number .this keyword is used in case of more accuracy .for example in case of PI value .Double stores 16 digits after decimal point
Char: char is used to indicate character .this may be character constant or single constant .it is enclosed in a pair of single quotes
modifers are used to minimze the storage .modifiers are prefixed with basic datatypes to modify (either increase or decrease ) the storage size
there are four modifiers in c language
short is used to decrease the memory size.int occupies 4bytes-64bit os,2bytes for 32bit os.if we use this short in 64bit ,size will be reduced 2
long is used to increase the size of the data type.this can be applied on int or double.if the size of int is 2 ,it changes to 4 bytes
This keyword accepts both negative or positive value and this is default properties or data type modifiers for every data type. in real time no need to write signed keyword explicitly for any data type.
This keyword can be used to make the accepting values of a data type is positive data type
below is the table for 16-bit processor.
Storage size and range for int and float datatype varies on 64-bit and 32-bit operating systems
|signed char||-128 to +127||1||%c|
|unsigned char||0 to 255||1||%c|
|short signed int||-32768 to +32767||2||%d|
|short unsigned int||0 to 65535||2||%u|
|signed int||-32768 to +32767||2||%d|
|unsigned int||0 to 65535||2||%u|
|long signed int||-2147483648 to +2147483647||4||%ld|
|long unsigned int||0 to 4294967295||4||%lu|
|float||-3.4e308 to +3.4e308||4||%f|
|double||-1.7e308 to +1.7e308||8||%lf|