Page 7 - basics of c
P. 7

Basic Data Types


           Integral Types



                 Integers are stored in various sizes. They can be signed

                    or unsigned.




                 Example


                    Suppose an integer is represented by a byte (8 bits).


                    Leftmost bit is sign bit.  If the sign bit is 0, the number is


                    treated as positive.


                    Bit pattern 01001011 = 75 (decimal).

                                                                                                       7
                    The largest positive number is 01111111 = 2 – 1 = 127.


                    Negative numbers are stored as two’s complement or as


                    one’s complement.


                    -75 = 10110100 (one’s complement).

                    -75 = 10110101 (two’s complement).
   2   3   4   5   6   7   8   9   10   11   12