1
|
- Binary and Denary Recap
- Hexadecimal
- Binary Sums
- Binary Fractions
|
2
|
- Denary Numbers
- Binary Numbers
- Converting to Denary
- Converting to Binary
- Questions
|
3
|
- Denary is the number system we use, base 10.
- We have 10 possible digits, 0-9.
- Each digit in a number has a different place value, working from the
right hand side place value increases in powers of 10.
- For example… with the denary number 5106
- And so is made up of
- (5×1000)+(1×100)+(0×10)+(6×1) =3D 5106
|
4
|
- Binary is the system used by electronics, i.e. a circuit is either o=
n or
off.
- Binary has just two possible digits, 1 or 0.
- Each digit in a number has a different place value, working from the
right hand side place value increases in powers of 2.
- For example, the binary 1011 is…
- And so is made up of
- (1×8)+(0×4)+(1×2)+(1×1)=3D 11
|
5
|
- So to convert from binary to denary you add up the value of each dig=
it.
- The value in denary is…
- (1×128) =3D 128
- (1×64) =3D 64
- (0×32) =3D 0
- (0×16) =3D 0
- (1×8) =3D 8
- (0×4) =3D 0
- (0×2) =3D 0
- (1×1) =3D 1
- Total is 128 + 64 + 0 + 0 + 8 + 0 + 0 + 1 =3D 201
|
6
|
- To convert a denary number into a binary number you need to invert t=
he
processes.
- Divide by powers of 2 and take the whole number part of each answer
(modular division).
- For example, to get the number 234 in binary…
- 234 ÷ 128 =3D 1 remainder 106
- 106 ÷ 64 =3D 1 remainder 42
- 42 ÷ 32 =3D 1 remainder 10
- 10 ÷ 16 =3D 0 remainder 10
- 10 ÷ 8 =3D 1 remainder 2
- 2 ÷ 4 =3D 0 remainder 2
- 2 ÷ 2 =3D 1 remainder 0
- 0 ÷ 1 =3D 0 remainder 0
- Therefore, the binary number is 1110 1010
|
7
|
|
8
|
- Hexadecimal Numbers
- Why Use Hexadecimal
- Converting to Binary
- Converting from Binary
- Reference Table
- Questions
|
9
|
- In hexadecimal (hex for short) we have 16 different digits, 0-9 (like
denary) and then an additional 6 digits. We use letters of the alpha=
bet
to represent these additional digits.
- In hex place value increases in powers of 16.
- For example, the hex number C3…
- Is calculated as
- =3D(0×256)+(C×16)+(3×1)
- =3D(0×256)+(12×16)+(3×1)
- =3D 195
|
10
|
- Hexadecimal numbers allow for larger numbers to be stored in the same
number of bits.
- This makes hex more efficient as well as easier to read than binary.=
- For example, to store the number 255 in binary requires eight digits
(1111111), in denary it requires three digits, whilst in hex it requ=
ires
only two (FF)
- Each hex digits requires one nibble (four bits) to store in the
computer’s binary memory.
|
11
|
- To convert to binary…
- Each hex digit must be individually converted into a denary number=
.
- That denary number is then converted into a four bit binary number=
.
- For example… To convert the number 5B into binary
- 5 à 5 in =
denary à 0101 in binar=
y
- B à 11 in=
denary à 1011 in binar=
y
- Therefore, 5B is shown as 0101 1011 in binary.
|
12
|
- To convert back from binary into hex you can split the binary number
into nibbles (blocks of four bits), starting from the right hand sid=
e.
- You then convert each nibble into its denary equivalent, and then in=
to a
single hex digit.
- For example, to convert the number 1101 1011 into hex…
- 1101 à 13=
in
denary à “D”
- 1011 à 11=
in
denary à “B”
- Therefore, the hex conversion is “DB”
|
13
|
|
14
|
|
15
|
- Addition
- Negative Binary
- More Negative Binary
- Subtraction
- Questions
|
16
|
- You add binary numbers just like denary ones, remembering that..
- 0 + 0 =3D 0
- 0 + 1 =3D 1
- 1 + 1 =3D 10 (or 0, and c=
arry the
1)
- For example…
- 001101
- + 011000
- Therefore, the answer is 100101
|
17
|
- In binary a negative number is represented with a sign bit, this is =
the
MSB (most significant bit).
- If the MSB is a 1, then the number is negative.
- To convert a number into its negative equivalent,
- Take the positive number in binary form
- Invert all the digits, so 1 becomes 0 and 0 becomes 1.
- Now add one to the resulting number.
- For example, negative 6 would be shown as
- -6 à -011=
0 à 1001 + 1 à 1010=
li>
|
18
|
- A simpler way of converting a positive to a negative is to follow th=
is
method…
- Starting from the right (least-significant bit, LSB)
- Leave all the digits up to and including the first ‘1’ alone.
- Invert all the remaining digits.
- For example, negative 6 in binary is
- -0110 à
19
|
- All a processor is capable of is binary addition, all other operatio=
ns
can be expressed in terms of addition.
- Subtraction is the result of adding a negative number, so to do the =
sum
6 – 4, you do 6 PLUS negative 4.
- For example…
- =3D 108 – 53
- =3D 01101100 – 00110101
- =3D 01101100 + 11001011
- =3D 00110111
|
|
20
|
|
21
|
- Fixed Point
- Floating Point in Denary
- Floating Point in Binary
- Converting from Floating Point
- Negative Floating Point
- Normalization
- Normalized Binary
- Questions
|
22
|
- With binary fractions place value still varies by powers of two.
- In fixed point binary the decimal place is fixed as being after a
certain amount of digits.
- For example, where the binary point is fixed after four digits, the
number 10011010 has a value of..
- =3D (1×8 ) + (1×1) + (1×0.5) + (1×0.0625)
- =3D 8 + 1 + 0.5 + 0.0625
- =3D 9.5625
|
23
|
- Floating point fractions are the equivalent of Scientific Notation in
denary.
- In Scientific Notation you have a sign, a mantissa and an exponent.<=
/li>
- For example, - 0.65 × 104
- ‘-’ is the sign
- ‘0.65’ is the mantissa
- ‘4’ is the exponent
- The number is raised to the power 10, since we are in denary.
|
24
|
- Typically 16 bits might represent a binary floating point value.
- The first 10 bits represent the mantissa, and the last 6 the exponen=
t.
- For example 0 100000000 000111
- ‘0’ is the sign of the mantissa
- ‘100000000’ is the mantissa
- ‘000111’ is the exponent
- The number is raised to the power 2, since we are in binary.
|
25
|
- To convert 0 100000010 000111 into denary…
- Convert the exponent into its decimal form.
- 000111 à=
4 + 2 +
1 =3D 7
- Consider that the mantissa is preceded by a decimal point, move th=
at
decimal point exponent times to the right.
- 100000010 à 1 0
0 0 0 0 0 1 0
- Now convert that value into denary, remembering that bits after the
decimal point are negative powers and therefore fractions. Don’t
forget the sign bit!
|
26
|
- Where the sign bit is negative, the overall number is negative.
- For example… 1 110000000 00001
- =3D - .110000000 × 2=
00001
- =3D - 1.10000000
- =3D - 1.5
- Where the exponent is negative, rather than moving the decimal point=
to
the right, you move it to the left.
- For example… 0 010000000 11111
- =3D + .010000000 × 2111111
- =3D + .010000000 × 2-00001
- =3D + .0010000000
- =3D + 0.125
|
27
|
- To be memory efficient all floating point numbers should be normalis=
ed.
- A normalised number can only be displayed in one way.
- For example in strict scientific notation 300 can only be shown as =
0.3×103
- However using a looser notation it could be shown as 300×100=
sup>,
30×101, etc.
- In normalized binary, the first bit of the mantissa after the sign b=
it
should always be a 1.
|
28
|
- To Normalize a binary number…
- Write the mantissa with the assumed decimal point in place.
- Shift the decimal point until it reaches the first 1.
- Subtract the number of places moved from the exponent.
- For example… Normalize 0 000110101 000010
- .000110101
- 0 0 0 1 1 0 1 0 1
- We moved the point 3 places, therefore we subtract 3 from the expo=
nent
of 2 (2 - 3 =3D -1)
- 0 110101000 111111
|
29
|
|