Canterbury Christ Church University

Week-6: Number Systems

Course Code: U19952

Course Name: Fundamentals of Computer Systems

Credits: 20

Module Leader: Ali Jaddoa
Canterbury Christ Church University

Outline

  • Information Theory
  • Binary
  • Hexadecimal
Fundamental of Computer Systems: U19952-2023-2024
Canterbury Christ Church University

Q) How does a computer store data?

Fundamental of Computer Systems: U19952-2023-2024
Canterbury Christ Church University

Information Theory : studies the quantification of information

  • A Mathematical Theory of Communication, (Shannon,1948)

    • Term bit was introduced as something that can have the representation of 1 or 0 most commonly an electrical signal
    • Foundations of the electrical computer was built off of this knowledge.
  • Sequences of bits have no intrinsic meaning except for the representation that we assign to them, both by convention and by building particular operations into the hardware.

Fundamental of Computer Systems: U19952-2023-2024
Canterbury Christ Church University

Binary

  • Computers store, transmit, manipulate, and calculate data using the binary numbering system.

  • It is represented in many forms as:

    • Positive or negative magnetic states
    • lands or pits, light passing or not, pulses of light, pulses of electricity, etc.
  • Binary can be used to represent any value you can imagine (numbers, images, etc. ).

  • The smallest unit is bit, either 0 or 1.

Fundamental of Computer Systems: U19952-2023-2024
Canterbury Christ Church University

Binary ()

  • Mathematically, we are working with base of 2 ().

  • The number of combinations:

  • For every bit you add, you double the possible combinations

    n 0 1 2 3 4 5 6
    2^n 1 2 4 8 16
    Answer 128
    Answer 265
  • You can calculate the maximum number you can have:

Fundamental of Computer Systems: U19952-2023-2024
Canterbury Christ Church University

Binary to Decimal

D num
1024 512 256 128 64 32 16 8 4 2 1
0 0 0 1 0 0 1 0 1 1 0
Answer 150
1 1 0 1 1 0 1 1 0 1 0
Answer 1754
1 0 1 0 1 0 1 0 1 0 1
Answer 1365
Fundamental of Computer Systems: U19952-2023-2024
Canterbury Christ Church University

Your turn

1024 512 256 128 64 32 16 8 4 2 1

  • Answer

  • Answer

Fundamental of Computer Systems: U19952-2023-2024
Canterbury Christ Church University

Decimal to Binary: Value =

Fundamental of Computer Systems: U19952-2023-2024
Canterbury Christ Church University

Another example: to Binary

Decimal Quotient Remainder (Binary)
61 - -
30 30 1
15 15 0
7 7 1
3 3 1
1 1 1
0 - -

So, 61 in decimal is 111101 in binary.

Fundamental of Computer Systems: U19952-2023-2024
Canterbury Christ Church University

Your Turn

  • Answer

  • Answer

Fundamental of Computer Systems: U19952-2023-2024
Canterbury Christ Church University

Hexadecimal ()

  • Hexadecimal is base 16
  • Alphabet : 0 1 2 3 4 5 6 7 8 9 A B C D E F
  • You can calculate the maximum number you can have:

16777216 1048576 65536 4096 256 16 1

Fundamental of Computer Systems: U19952-2023-2024
Canterbury Christ Church University

Hexadecimal, Binary, Decimal

Binary
Unsigned Int 15 14 13 12 11 10 9 8
Hexadecimal F E D C B A 9 8
Binary
Unsigned Int 7 6 5 4 3 2 1 0
Hexadecimal 7 6 5 4 3 2 1 0

Fundamental of Computer Systems: U19952-2023-2024
Canterbury Christ Church University

Hexadecimal to Binary

  • Break the binary number into groups of 4 binary digits, why

    Answer

  • Each group represnt values from 0-15 (F)

Binary Grouped Bits Hexadecimal
11111011 1111 1011
Answer FB
00011010 0001 1010
Answer 1A

Fundamental of Computer Systems: U19952-2023-2024
Canterbury Christ Church University

Hexadecimal to Decimal

In hex each position's weight should be 16 times the previous.

4096 256 16 1

Fundamental of Computer Systems: U19952-2023-2024
Canterbury Christ Church University

Hexadecimal to Decimal

The conversion can be done between 1 and 4 hexadecimal positions, much like Hexadecimal Binary.

4096 256 16 1

Fundamental of Computer Systems: U19952-2023-2024
Canterbury Christ Church University

Endianness: Little or Big Endian

  • Order in which a sequence of bytes is stored/read in a computer’s memory
    • Big endian: first byte is the most significant (Left)
    • Little endian: first byte is the least significant

  • Intel processors use little endian
  • ISO standard for network address is big endian
Fundamental of Computer Systems: U19952-2023-2024
Canterbury Christ Church University

Exmaple:

= 12 34 56 78

Big Endian =

Answer

Little Endian =

Answer

Fundamental of Computer Systems: U19952-2023-2024
Canterbury Christ Church University

Representing Characters

  • Computers use numeric encodings to represent character data inside the memory of the machine, in which each character is assigned an integral value.

  • Character codes, however, are not very useful unless they are standardised. When different computer manufacturers use different coding sequence (as was indeed the case in the early years), it is harder to share such data across machines.

  • The first widely adopted character encoding was ASCII (American Standard Code for Information Interchange).

Fundamental of Computer Systems: U19952-2023-2024
Canterbury Christ Church University

American Standard Code for Information Interchange

ASCII Table

Dec Char Dec Char Dec Char Dec Char Dec Char Dec Char Dec Char Dec Char
32 SPACE 45 - 58 : 71 G 84 T 97 a 110 n 123 {
33 ! 46 . 59 ; 72 H 85 U 98 b 111 o 124
34 " 47 / 60 < 73 I 86 V 99 c 112 p 125 }
35 # 48 0 61 = 74 J 87 W 100 d 113 q 126 ~
36 $ 49 1 62 > 75 K 88 X 101 e 114 r 127 DEL
37 % 50 2 63 ? 76 L 89 Y 102 f 115 s
38 & 51 3 64 @ 77 M 90 Z 103 g 116 t
39 ' 52 4 65 A 78 N 91 [ 104 h 117 u
40 ( 53 5 66 B 79 O 92 \ 105 i 118 v
41 ) 54 6 67 C 80 P 93 ] 106 j 119 w
42 * 55 7 68 D 81 Q 94 ^ 107 k 120 x
43 + 56 8 69 E 82 R 95 _ 108 l 121 y
44 , 57 9 70 F 83 S 96 ` 109 m 122 z

Can 256-character codes accommodate all the characters in other languages, e.g., Chinese, Japanese, Greek, etc.?

Answer
  • NOT A CHANCE
  • With only 256 possible characters, the ASCII system proved inadequate to represent the many alphabets in use throughout the world.
Fundamental of Computer Systems: U19952-2023-2024
Canterbury Christ Church University

Unicode

  • It has therefore been superseded by Unicode, which allows for a much larger number of characters.
  • Worldwide standard for processing, displaying and interchanging all types of language texts
  • Uses 2 bytes per character 16 bits 65,536 code points each point has 17 planes, 1,114,112 characters

Exmaple

Type Value
ASCII 41h
Unicode 4100h
Fundamental of Computer Systems: U19952-2023-2024
Canterbury Christ Church University

Binary as a signal

Fundamentally, binary is electrical signals represented as 1 or 0, a sequence of eight is mapped to the decimal number which in turn is mapped to a ASCII symbol.

00100001 = 33 = !

*take note, these last 3 slides are helpful for the practical part of the assignment.

Fundamental of Computer Systems: U19952-2023-2024
Canterbury Christ Church University

Labs

In addition to your lectures in Mathematics in Computer Science (For Business students, please get in touch with me if you need more help and support, and I will be happy to set up tutorials), I'm providing an extra lab for you to work on in your own time

  1. Numbering systems conversion: Lab here
Fundamental of Computer Systems: U19952-2023-2024

--- ## Binary <div align=center> |Decimal | Binary||Decimal|Binary |---|---|----|---|---| |0|000000||10|001010| |1|000001||11|001011| |2|000010||12|001100| |3|000011||13|001101| |4|000100||14|001110| |5|000101||15|001111| |6|000110||16|001000| |7|000111||17|010001| |8|001000||...|...| |9|001001||63|111111| </div>

Therefore the decimal equivalent value is: $$ \begin{aligned} 1 \cdot 2^7 &= 128_{10}\\ 1 \cdot 2^4 &= \hspace{0.5em}16_{10} \\ 1 \cdot 2^2 &= \hspace{1em} 4_{10} \\ 1 \cdot 2^1 &= \hspace{1em} 2_{10} \hspace{0.5em}+ \\ \hline [0]000 \ 1001 \ 0110_2 &\equiv 150_{10} \end{aligned} $$

![](../../figures/endian.png)

1. Second lab is all in `c` and we will be writing a program to convert: Lab [here]() - decimal $\longleftrightarrow$ binary - binary $\longleftrightarrow$ hex - hex $\longleftrightarrow$ decimal We may not get through all of this today, luckily for you have 50hrs of self learning for this module.