Chapter 2.3 - Identify the various C data types | Part - 2


Integer Types

Integers are whole numbers with a range of values supported by a particular machine. Generally, integers occupy one word of storage, and since the word sizes of machine vary (typically, 16 or 32 bits) the size of an integer that can be stored depends on the computer. If we use a 16-bit word length, the size of the integer is limited to the range -32768 to +32767 (that is, -215 to  + 215  -1). A signed integer uses one bit for a sign and 15 bits for the magnitude of the number, Similarly, a 32-bit word length can store an integer ranging from -2,147,483,648 to 2,147,483,647.


C Language Tutorials for Beginners                      



C data types


In order to provide some control over the range of numbers and storage space, C has three classes of integer storage, namely short int, int, and long int, in both signed and unsigned forms. ANSI C defines these types so that they can be organized from the smallest to the largest, as shown in the following Fig. 2.5. For example, short int represents fairly small integer values and requires half the amount of storage as a regular int number uses. Unlike signed integers, unsigned integers use all the bits for the magnitude of the number are always positive. Therefore, for a 16-bit machine, the range of unsigned integer numbers will be from 0 to 65,535. #c_datatype

We declare long and unsigned integers to increase the range of values. The use of qualifier signed on integers is optional because the default declaration assumes a signed number. Table 2.8 shows all the allowed combinations of basic types and qualifiers and their size and range on a 16-bit machine. #datatypes

                Download Turbo C++ Program Compiler


            Download Free Code::Block All Program Compiler


Identify the various C data types | Part - 2
Note: C99 allows long long integer types. See the Appendix "C99 Features"

 C data types





Floating Point Types

Floating point (or real) numbers are stored in 32 bits (on all 16 bit and 32-bit machines), with 6 digits of precision. Floating point numbers are defined in C by the keyword float. When the accuracy provided by a float number is not sufficient, the type double can be used to define the number. A double data type number uses 64 bits giving a precision of 14 digits. These are known as double precision numbers. 


Identify the various C data types | Part - 2

Remember that double type represents the same data type that float represents, but with greater precision. To extend the precision further, we may use long double which uses 80 bits. The relationship among floating types is illustrated in Fig 2.6.



Void Types

The void types have no values. This is usually used to specify the type of functions. The type of function is said to be void when it does not return any value to the calling function. It can also play the role of a generic type, meaning that it can represent any of the other standard types. 

        Top 10 Useful Commands for Linux Users

       C Programming Example Tutorial



Character Types


A single character can be defined as a character (char) type data. Characters are usually stored in 8bits (one byte) of internal storage. The qualifier signed or unsigned may be explicitly applied to char. While unsigned chars have values between 0 and 255, signed chars have valews from -128 to 127. #allaboutprogramming62

Post a Comment

2 Comments

Ask Me Everything About Programming.