Unit 6 - Data Types Flashcards
binary addition rules
- 0 + 0 = 0
- 0 + 1 = 1
- 1 + 1 = 0 carry 1
- 1 + 1 + 1 = 1 carry 1
what is an overflow
when the arithmetic result exceeds the available number of bits
what does one shift to the left do
x 2
what does one shift to the right do
/2
how does twos complement work
-128, 64, 32, 16, 8, 4, 2, 1
how to work out if the denary value will be positive or negative in twos complement
starts with 0 = positive
starts with 1 = negative
how convert a negative denary number to binary
- flip all of the bits
- add 1
how to convert a negative twos complement binary number to denary
- flip the bits
- add one
- negative sign in-front of byte
- convert
how to do binary subtraction using twos complement
- convert negative binary number into twos complement
- add positive binary value and twos complement value
why are fixed point binary number useful
- represent fractions in binary
- increased performance
what is limited by fixed point binary
- range
advantages of floating point binary
- greater range
- greater accuracy
what does moving the point to the right in floating point binary do
increase range
reduces precision
what does moving the point to the left in floating point binary do
reduces range
increases precision
what is the mantissa
the coefficient
what is the exponent
the order of magnitude
positive exponent means
decimal point moves right
negative exponent means
decimal point moves left
how to handle negative exponents
- twos complement of exponent
- move the binary point of the mantissa by exponent to the left
- translate to denary
how to handle negative mantissas
- find twos complement of mantissa
- translate exponent to denary
- move binary point by exponent to the right
- translate this to binary
what does the sign bit show
positive or negative value of mantissa
- 0. = positive
- 1. = negative
what is normalisation
process of moving the binary point of a floating point number to provide the maximum level of precision for a given number of bits. this is achieved by ensuring that the first digit after the binary pin t is a significant digit
how to normalise a positive binary number
a positive number has a sign but if 0 and the next digit is always 1. this means the mantissa of a positive number in normalised for always lies between 1/2 and 1
normalising a negative binary number
a normalised negative number has a sign but of 1 and the next bit is always 0
increase size of mantissa
greater precision
increase size of exponent
increase range
how convert from denary to normalised binary floating point
- convert to fixed point binary
- then use an exponent to make the mantissa normalised
how to do floating point addition and subtraction
- line up the points by making the exponents equal
- add or subtract the mantissas
- normalise the result
what is an under flow error
when a result is to small to be represented by the allotted number of bits
what is a logical shift
all the bits move right or left. a logical shift causes the least significant bit to be shifted into the carry bit and a zero moves into the most significant bit to occupy the vacated space
what is an arithmetic shift
similar to a logical shift but takes into account the sign bit, which always remains the same. therefore the first or last bit of the mantissa moves into the carry bit and the sign bit remains the same
how to multiply two binary numbers
- use addition and shifts
what is a circular shift
a rotate or circular shift is useful for performing shifts in multiple bytes. in a circular shift right, the value in the least significant bit is moved into the carry bit, and the carry bit is moved into her most significant bit
what does an AND mask do
extracts
- to clear a particular bit, use a mask of 0 and the AND operator
- use a mask of 1 to leave a bit unchanged
what does an OR mask do
sets
- to set a particular bit, use a mask of 1 and the OR operator.
- use a mask of 0 to leave a bit unchanged
what does an XOR mask do
toggles
- to toggle a particular bit, use a mask of 1 and the XOR operator
- use a mask of 0 to leave a bit unchanged
order of binary prefixes
- kibi- KiB - 2^10
- mebi - MiB - 2^20
- gibi- GiB - 2^30
- tebi- TiB - 2^40
what is a primitive data type
one which is provided by a programming language
what is a composite data type
not considered a primitive data type for example an array
name the number bases and their base
denary - base 10
binary - base 2
hexadecimal - base 16
name the character sets
- 7-bit ASCII
- 8-bit ASCII
- Unicode
how do character sets represent text
each character, number and symbol has a uniquely defined code