Data Representations in Computer Programs
Representations and Conversions

Integers
A single byte can store an integer that takes on a value from 0 to 255.  The interpretation of the bits in the byte uses normal binary representations for numbers.  You might not see this representation often.
unsigned char x;


A single byte can also store an integer that takes on a value from -128 to +127.  In this case, one bit in the byte is used as a sign bit.  In C, an integer of this type is declared using:

char x;
or
short int x;
Larger integers can be stored using two bytes.  Two bytes can store 216 - 1 or 65536 numbers from 0 to 65535.  The numbers represented can run from 0 to 65535.  In C, an integer of this type is declared using:
 unsigned int x;
Signed integers take two bytes and use one bit to store the sign (plus or minus), and have a range from -32768 to +32767, and are declared like this:
 int x;
NOTE:  In some cases, the declaration above will give you an integer that takes four bytes, and which can have much larger values.

Finally, there is a long integer that is used for large integers.  A long integer takes four bytes, and will handle integers from -2,147,483,648 to -2,147,483,647.  The form of the declaration is:

 long int x;
Now, none of these representations will handle something like 2.59 - a number that is not an integer.  You need to use a floating point representation for those numbers.
 
Data Type
Number of Bytes
Number of Bits
Float
4
32
Double
8
64
Long Double
12
96

                float    4      32
               double    8      64
          long double   12      96

Floating Point Numbers

        IEEE has written a standard for floating point numbers.  The simplest IEEE representation uses a 32 bit word (four bytes) and looks something like this:

        This representation can be difficult to unravel, but S is the sign bit, and the eight bit "E" number is a signed integer representing the exponent.  The "F" number determines the mantissa and is actually the floating point part in a 1.X representation, where X is the number represented by F.  A four bit floating point number has a declaration like this.         What you need to remember is that a floating point number is stored as an exponent and a mantissa along with a sign.  That means that - in the four byte representation - there are only 24 bits devoted to the mantissa (significant figures) and you have to remember not to overestimate how precise the representation is.

        If you want a more precise representation of a number, you can use a double precision floating point representation that uses eight (8) bytes.  The declaration is:


ASCII coded numbers

        Numerous instruments transmit measurement data using ASCII coded numbers.  In an ASCII coded number.  For example, a measurement that yields a value 3.145 would be transmitted to a computer with the following sequence of characters.

        This approach can be used to put data into a file for data storage. Most data files use this representation.  For details on the ASCII code, click here.