2.1 BInary (B02) Flashcards
why do computers use binary?
A computer’s electronic circuits consist of hundreds of thousands of tiny switches, called transistors.
they can be either on or off. When a transistor is on it produces a ‘1’ and when it is switched off, it produces a ‘0’.
Transistors can switch on and off thousands of times per second, which enables computers to process huge amounts of data very quickly.
most significant bit
the one with most value (furthest to the left)
how to do denary -> binary
divide X by 2, find quotient, find remainder (remainder is bit 1)
divide quotient by 2, find new quotient, find remainder (remainder is bit 2)
keep going!
overflow
happen when the largest number that a register can hold is exceeded. The number of bits that it can handle is called (strangely) the word size
adding 1 to a binary number
Loop through the digits of the original number from the RIGHT:
If you find a 1, change it to 0.
If you find a 0, change it to 1 and STOP.
All remaining digits are unchanged.
how to represent negative binary
Two’s Compliment:
Start with the 8-bit representation of the equivalent positive integer.
Reflect each bit of the bit pattern (change 0 to 1, and 1 to 0).
Add one.
errors when manipulating unsigned integers
If the result is too large to fit into the number of bits assigned to it, an “overflow” is said to have occurred. For example if the result of an operation using 16 bit integers is larger than 65,535, an overflow results.
If the result is below zero (e.g. 54 – 58), then how is the computer meant to represent it as a minus number, given that it stores data using only 0s and 1s?
In the division of two integers, if the result is not itself an integer, a “truncation” is said to have occurred: 10 divided by 3 is truncated to 3, and the extra 1/3 is lost.
Any division by zero is an error, since division by zero is not possible in the context of arithmetic.
what range of numbers can be represented using 8 bits (w/ Two’s compliement)
-128 to +127
bitwise operation
another name for shifts
logical vs arithmetic shift
what symbols does hexadecimal use
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.
why is hexadecimal used
computers do not store data in hexadecimal format. They only ever use binary. Hex benefits humans, not computers:
Binary produces long strings and can be difficult to work with. Hex is shorter.
Strangely, it is easier to convert numbers from binary to denary when using hexadecimal.