AD Computer Science Flashcards
What is a digital computer?
a computer that accepts and processes data that has been converted into binary numbers.
What is binary and why do we use it?
These are transistors. They are tiny electrical components that form the basis of all digital computing devices. They have two distinct states: 1 - On 0 - Off
What kind of data do we store?
Text, image, audio, numbers.
Bits
A bit is the smallest unit of information that can be processed inside a computer.
A bit can hold one of two symbols, 0 or 1.
`
How many patterns?
2ⁿ
1 bit - 2 values = 0, 1.
3 bits - 8 values = 000,001,011,100,110,010,111,011.
Nibbles
A set of 4 bits is called a nibble.
A single nibble can store 16 unique values (2⁴) - the denary numbers 0 - 15.
Bytes
Two nibbles make a byte.
A byte is 8 binary digits.
Is the standard unit of measurement in digital computing.
Represents 256 values (0-255).
Most significant bit
Refers to the leftmost bit.
Has the largest place value.
Rules for binary addition
0 + 0 = 0
0 + 1 = 1
1 + 1 = 0 carry 1
1 + 1 + 1 = 1 carry 1
Overflow error
Overflow error means that the result of the calculation is too large for the space allocated.
The way a computer handles this will depend on how its set up:
It could crash and report an overflow error.
It could truncate the answer.
It could wrap the number around back to 0.
Sign and magnitude
The most significant bit is the ‘sign bit’.
1= minus
0 = positive
Problems with sign and magnitude
Waste one binary code.
Both 1000 0000 and 0000 0000 represent 0.
Addition doesn’t always work.
Two’s complement
The MSB is a minus number as well as a sign bit.
The largest positive number that can be represented is +127 (0111 1111)
The largest negative number that can be represented is -128 (1000 0000)
If it’s positive, make sure to write the + sign.
Denary to binary (negative numbers)
Convert the unsigned equivalent into 8 bit binary Flip the bit (each 1 becomes a 0 and vice versa) Add 1 (arithmetically, not appending)
Left shifting
Logical left shifting
MSB is shifted out of the pattern.
Each remaining bit is shifted left.
A new 0 is placed into all vacated spot
Arithmetic left shifting
Same as logical left shifting
Right shifting
Logical right shifting
A 0 is always inserted into the vacated MSB.
A 0 is always placed into all vacated spots
Arithmetic right shifting
The MSB is always maintained and copied into all vacated spaces.
Binary to Hexadecimal
Binary to Hexadecimal
0110 - 1111
6 - 15
6 - F
Hexadecimal to Binary
B - E
11 - 14
1011 - 1110
BE - 1011 1110
Denary to hexadecimal
Denary to Hexadecimal
58₁₀
16 - 1
3 - 10
3 - A
Hexadecimal to denary
Hexadecimal to denary
27₁₆
16 - 1
2 - 7
(32) - (7)
39₁₀
ASCII
One way to encode binary to store text is to use ASCII.
ASCII is the American Standard Code for Information Interchange.
Why is it necessary?
Imagine if everyone used a different encoding scheme for text.
They would not be able to communicate.
ASCII enables computing devices to communicate with another and to translate their communication into identical information.
Bit patterns
ASCII uses 7 bits.
128 patterns.
A - 65 - 0100 0001
a - 97 - 0110 0001
Limitations of ASCII
ASCII represents 128 unique characters.
ASCII is suitable for English (and languages that use the same characters) but it cannot represent languages that have additional different characters.
French, German and Mandarin are examples of languages that do not fit into ASCII.
For these languages Unicode was created.
The first version is able to represent 120,000 characters such as:
÷ x ᵀᴹ ©
Von Neumann Architecture
Every computer is made up of:
A processing unit that contains an ALU and processor registers.
A control unit that contains an instruction register and program counter register,
Memory that stores both data and instructions.
External data storage.
Input and output mechanisms.
Fetch
CPU fetches data and instructions from RAM.
CPU stores in its own memory called registers.
CPU uses address bus.
The memory address of the next item in the CPU wants is put onto the address bus.
Data from this memory travels from RAM to CPU on the data bus.