Data species in c refer to substantial system provided for proclaiming variables or attributes of different types. The type of a change determines exactly how much space it occupies in storage and how the little bit pattern stored is interpreted.
You are watching: How many bytes in a float
The types in C have the right to be classified as complies with −
They space arithmetic types and are additional classified into: (a) integer types and (b) floating-point types.
They room again arithmetic species and they are used to specify variables that can only assign specific discrete integer values throughout the program.
The type void
The type specifier void shows that no value is available.
They encompass (a) tip types, (b) array types, (c) framework types, (d) Union types and (e) role types.
The array types and structure varieties are referred jointly as the aggregate types. The form of a function specifies the type of the function"s return value. We will view the straightforward types in the complying with section, whereby as other species will be covered in the upcoming chapters.
See more: How Many Cups Is 6 Quarts In Cups? Convert 6 Quarts To Cups
The complying with table provides the details of traditional integer types with your storage sizes and value ranges −
To gain the exact size the a type or a variable on a details platform, you deserve to use the sizeof operator. The expressions sizeof(type) returns the storage dimension of the object or type in bytes. Given listed below is an instance to acquire the size of various type on a device using different continuous defined in limits.h header record −
#include #include #include #include int main(int argc, char** argv) printf("CHAR_BIT : %d ", CHAR_BIT); printf("CHAR_MAX : %d ", CHAR_MAX); printf("CHAR_MIN : %d ", CHAR_MIN); printf("INT_MAX : %d ", INT_MAX); printf("INT_MIN : %d ", INT_MIN); printf("LONG_MAX : %ld ", (long) LONG_MAX); printf("LONG_MIN : %ld ", (long) LONG_MIN); printf("SCHAR_MAX : %d ", SCHAR_MAX); printf("SCHAR_MIN : %d ", SCHAR_MIN); printf("SHRT_MAX : %d ", SHRT_MAX); printf("SHRT_MIN : %d ", SHRT_MIN); printf("UCHAR_MAX : %d ", UCHAR_MAX); printf("UINT_MAX : %u ", (unsigned int) UINT_MAX); printf("ULONG_MAX : %lu ", (unsigned long) ULONG_MAX); printf("USHRT_MAX : %d ", (unsigned short) USHRT_MAX); return 0;When you compile and execute the above program, that produces the following an outcome on Linux −
Floating-Point TypesThe adhering to table administer the details of traditional floating-point types with warehouse sizes and also value ranges and their precision −
|float||4 byte||1.2E-38 come 3.4E+38||6 decimal places|
|double||8 byte||2.3E-308 come 1.7E+308||15 decimal places|
|long double||10 byte||3.4E-4932 to 1.1E+4932||19 decimal places|
The header paper float.h specifies macros that enable you to usage these values and also other details about the binary depiction of actual numbers in your programs. The following instance prints the storage an are taken by a float kind and its range values −
#include #include #include #include int main(int argc, char** argv) printf("Storage size for to rise : %d ", sizeof(float)); printf("FLT_MAX : %g ", (float) FLT_MAX); printf("FLT_MIN : %g ", (float) FLT_MIN); printf("-FLT_MAX : %g ", (float) -FLT_MAX); printf("-FLT_MIN : %g ", (float) -FLT_MIN); printf("DBL_MAX : %g ", (double) DBL_MAX); printf("DBL_MIN : %g ", (double) DBL_MIN); printf("-DBL_MAX : %g ", (double) -DBL_MAX); printf("Precision value: %d ", FLT_DIG ); return 0;When friend compile and execute the above program, it produces the following an outcome on Linux −
Storage size for rise : 4 FLT_MAX : 3.40282e+38FLT_MIN : 1.17549e-38-FLT_MAX : -3.40282e+38-FLT_MIN : -1.17549e-38DBL_MAX : 1.79769e+308DBL_MIN : 2.22507e-308-DBL_MAX : -1.79769e+308Precision value: 6
The void TypeThe void kind specifies the no worth is available. That is supplied in three kinds of situations −
Function returns as void
There space various features in C which perform not return any type of value or you have the right to say lock return void. A function with no return value has actually the return form as void. For example, void departure (int status);
Function debates as void
There room various features in C which carry out not accept any parameter. A function with no parameter deserve to accept a void. Because that example, int rand(void);
Pointers to void
A guideline of type void * represents the deal with of an object, however not that is type. Because that example, a storage allocation duty void *malloc( size_t dimension ); returns a guideline to void which deserve to be casted to any kind of data type.