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