Sie sind auf Seite 1von 3

Conversion between Binary and Decimal

Generally logical 0 represents a potential difference of 0V


In the same manner logical 1 represents 5V
Logical 0 occurs when current cannot flow (e.g. through an open
switch)
Logical 1 occurs when current can flow (e.g. through a closed
switch) and there is some current being supplied (e.g. from the
Vcc pin on Integrated Circuits)

Binary Notation
Binary numbers are in base 2. This is because each digit can only
be one of 2 numbers, i.e. 0 or 1.
Decimal numbers (the ones we most commonly use) are in base
10. Each digit can be either 0,1,2,3,4,5,6,7,8, or 9.
Binary numbers are represented with a % prefix or a 2 subscripted
suffix.
Decimal numbers can have a 10 subscripted suffix. (This means
that there is a little 10 after the number!)

Conversion from Binary to Decimal


If you want to make life easy for yourself get a calculator which
can work in different bases!
In Decimal we are used to thinking about numbers as a
combination of Units, Tens, Hundreds, etc.
107 106 105 104 103 102 101 100
1000000 100000 10000 1000
1000 100 10 1
0 0 0 0
For Example: 1652 (base 10) = 1 Thousand + 6 Hundreds +5 Tens
+ 2 Units.

1
In Binary we can think of numbers as a combination of Ones,
Twos, Fours, Eights, Sixteen's, etc.
27 26 25 24 23 22 21 20
128 64 32 16 8 4 2 1
Similarly: %10110 (base 2) = 1 sixteen + 1 four + 1 two = 22 (in
base 10)
Or: %1100101 = 1 sixty-four + 1 Thirty-two + 1 four + 1 one =
10110
27 26 25 24 23 22 21 20
128 64 32 16 8 4 2 1
1 1 0 0 1 0 1
64 +32 +0 +0 +4 +0 +1 =10110

So: 11001012 = 10110


Conversion from Decimal to Binary
Divide the number repeatedly by 2 (Answer being a whole
number and a remainder, The same as Modula-2 Div and Mod
commands)
The First remainder is the LSB (Least Significant Bit or Digit, the
digit on the right of the number) of the Binary number. The next
remainder is the next digit, and so on until the value is 0.
For Example: Convert 145 into base 2.
145/2= 72 r 1
72/2= 36 r 0
36/2= 18 r 0
18/2= 9 r0
9/2= 4 r1
4/2= 2 r0
2/2= 1 r0

2
1/2= 0 r1
So: 14510 = %10010001

Das könnte Ihnen auch gefallen