Sams Teach Yourself C in 21 Days

(singke) #1

APPENDIX C


Working with Binary and


Hexadecimal Numbers


As a computer programmer, you might sometimes be required to work with
numbers expressed in binary and hexadecimal notation. This appendix explains
what these systems are and how they work. To help you understand, let’s first
review the common decimal number system.

The Decimal Number System

The decimal system is the base-10 system that you use every day. A number in
this system—for example, 342—is expressed as powers of 10. The first digit
(counting from the right) gives 10 to the 0 power, the second digit gives 10 to
the 1 power, and so on. Any number to the 0 power equals 1, and any number
to the 1 power equals itself. Thus, continuing with the example of 342, you
have:

46 448201x-APP C 8/13/02 11:22 AM Page 793

Free download pdf