Cryptography Reference
In-Depth Information
APPENDIX
A
Binary Representation of
Integers: A Primer
If you know how to program in C, you must have spent some time looking at
machine-level details, including binary number representations, as you learned
it. This appendix covers some of these details that you were probably familiar
with at one point, but have since (maybe willfully) forgotten.
The Decimal and Binary Numbering Systems
Humans use a base-10 numbering system. Ten unique digits (including 0) rep-
resent the fi rst nine ordinal numbers. After the ninth position, you use multiple
digits to represent numerals. Anthropologists believe that the base-10 num-
bering system, which is ubiquitous in almost all human societies, came about
because humans have 10 fi ngers. As it turns out, though, computers have just
one such “fi nger” because they're electrical machines. I'll go out on a limb and
assume you interact with electricity at least occasionally when you turn on a
light switch — the switch is the counter which can be in two states: on and off.
If it's on, electricity fl ows; if it's off, it doesn't.
To grossly oversimplify, a CPU is nothing but a series of interrelated elec-
tronic switches. Numbers are represented by unique combinations of multiple
switches. One such switch can count two unique values. Two switches can
count four: on-on, on-off, off-on and off-off. Three switches can count eight
values, and n switches can count 2 n values. Most modern computers are said
Search WWH ::




Custom Search