theory term 1-2 Flashcards
what is a bit?
smallest bit of data that can be represented (0 or 1)
what is a nibble?
4 bits
what is a byte?
8 bits (2 nibbles)
what are some types of data?
number (signed/unsigned)
images
audio
text
what is an overflow error?
when the result of a calculation is too large to be represented in the amount of bits allocated
what is a signed integer?
a positive or negative number that has been assigned a positive or negative value.
what is an unsigned integer?
positive integer or zero, as it has not been assigned as + or -.
what is sign and magnitude?
sign = most significant bit (positive = 1 and negative = 0)
magnitude = the rest of the byte, size of number
what are some flaws with sign and magnitude?
- a bit pattern is wasted
- addition does not work in the desired way
- it has 2 ways of representing 0
- arithmetic works in 2s compliment and not in sign and magnitude
- you cannot represent a negative sign in binary
what is two’s complement?
most common way of representing signed binary integers.
the first digit, if a one, means that one is negative, and then you perform your calculation as normal
what are some benefits of two’s complement?
- only one way of representing 0
- arithmetic works
how do you convert integers into two’s complement?
step 1:
BINARY FLIP ADD
- write down the positive value of the integer in binary
eg. 3 = 0011 - flip each bit
eg. 3 = 1100 - perform binary addition with your flip by adding 0001
eg. 1101
= -8 + 4 + 1 = -3!
what is a left logical shift?
a left logical shift by 1 = * 2
a left logical shift by 2 = * 4
most significant bit is shifted left and out of the bit pattern
all the other bits move left
a filler 0 is placed in the least significant bit
what is a right logical shift?
a right logical shift by 1 = / 2
a right logical shift by 2 = / 4
the least significant bit is shifted right and out of the bit pattern
all the other bits move right
a filler 0 is placed in the most significant bit
+ LOSS OF PRECISION!! 23 / 2 = 11.5, and that cannot be represented in binary. is truncated ig lol, you dont keep the decimal even if it’s 0.99
what is a left arithmetic shift?
a left arithmetic shift by 1 = * 2
a left arithmetic shift by 2 = * 4
most significant bit is shifted left and out of the bit pattern
all the other bits move left
a filler 0 is placed in the least significant bit
what is a right arithmetic shift?
a right arithmetic shift by 1 = / 2
a right arithmetic shift by 2 = / 4
the least significant bit is shifted right and out of the pattern
all the other bits move left
THE VALUE OF THE LEAST SIGNIFICANT BIT IS COPIED INTO WHATEVER IS EMPTY (BECOMES THE FILLER)
- this is why right arithmetic shift is better, as it maintains sign (negative signs) !
- it can overflow error however (bit of an L)
what is hexadecimal?
an alternative method of representing long binary numbers.
hexadecimal is a base 16 number system.
what is A ^16
10 ^ 10 = 1010 ^ 2 and A ^ 16
what is F ^ 16
15 ^ 10 = 1111 ^ 2 = F ^ 16
how do you convert between binary and hexadecimal?
divide your byte into nibbles!
eg.
0110 1100
4 +2 = 6 8 + 4 = 12 = C
0110 1100 = 6C
how do you convert between hexadecimal and binary?
B E
B = 11 E = 15
1011 1111
BE = 1011 1111
what is a common use for hexadecimal?
colours
what is ASCII?
a standard way to encode text on early computers
7 bits
how do you differentiate A from a?
- difference of 32 in denary
- the 32 bit is filled in on one, and not on the other
A = 0100 0001
E = ?
E - A = 4 in between them
= fill in the 4 bit on the binary digit
0100 0101
how many characters does ASCII represent?
128
how many characters does extended ASCII represent?
512
how many characters does unicode represent?
120,000
why was unicode created?
ASCII did not support other languages, eg. french, german, cyrillic and mandarin