[ 1.4.1 ]
what is an integer?
a whole number
zero is an integer
negative numbers are integers
can’t have a fractional part
what are real/floating point numbers?
any positive or negative numbers
can, but do not necessarily, have a fractional part
useful for measuring things
all integers are real numbers
what is a character?
a single symbol used by a computer
the letters A to Z
the numbers 0 to 9
symbols like %, £, and #
what is a string?
a collection of characters
can be used to store a single character
can also be used to store many characters in succession
useful for storing text
don’t cut off leading 0s like numeric types (floats/ints)
what is a boolean value?
values restricted to True or False
useful for recording data that can only take two values
what is a bit?
a single binary digit
what is a byte?
eight bits
what is a nybble?
half a byte // four bits
what is the most significant bit?
the bit furthest to the left
how do you make a number negative by using the sign and magnitude method?
add a leading 1 to signify a negative number
how do you make a number negative by using the two’s complement method?
take the positive binary number and ‘flip‘ all the bits
then add 1
what are the four rules of binary addition?
0 + 0 = 0
0 + 1 = 1
1 + 1 = 10
1 + 1 + 1 = 11
how do you perform binary subtraction?
subtracting a number from another is the same as adding a negative number
to subtract in binary, use binary addition with a negative two’s complement number
how do you convert a hexadecimal number into a binary number?
first convert any hexadecimal characters to a decimal number
convert each number to a binary nybble
combine the nybbles to form a single binary number
how do you convert a hexadecimal number into a denary number?
first convert to binary, and then convert from binary to decimal
alternatively, use the place values of hexadecimal to convert directly to denary (the nth place is equivalent to 16n)
what are the two components of a floating point binary number?
the mantissa and the exponent
what is the exponent?
a two’s complement number
part of a floating point number, shows the position of the decimal point in the number
it represents the number of places the decimal point should move forwards or backwards
if the exponent is positive the decimal point moves backwards
if the exponent is negative the decimal point moves forwards
what is the mantissa?
a two’s complement number
part of a floating point number, the number itself
it is always taken to have the binary point after the most significant bit
why do we normalise floating point numbers?
maximises precision in a given number of bits and ensures there is only one way to store any given number
how do you normalise a floating point number?
adjust the mantissa so that it starts with 01 for a positive number
adjust the mantissa so that it starts with 10 for a negative number
what is the effect of increasing the number of bits used for the mantissa?
can store more accurate numbers
what is the effect of increasing the number of bits used for the exponent?
can store a wider range of numbers
how do you add floating point numbers?
to add floating point binary numbers, their exponents need to be the same
then add the mantissas
finally, normalise the result if required
how do you subtract floating point numbers?
involves converting to two’s complement and adding
the exponents must be the same
make the number being subtracted negative using two's complement
then add the mantissas
what is a shift?
moving all of the bits in a binary number a specified number of places to the right or to the left
this can be thought of as adding a number of leading/trailing zeros
what is the affect of shifting a number n spaces left?
multiplication by 2n
what is the affect of shifting a number n spaces right?
division by 2n
what is a mask?
combining one or more binary numbers with a logic gate
what is a character set?
a published collection of codes that correspond to characters
can be used by computers for representing text
two widely used character sets are ASCII and Unicode
what is ASCII?
American Standard Code for Information Interchange
was the leading character set before Unicode
uses 7 bits to represent 27 (128) different characters
ASCII soon came into trouble when computers needed to represent other languages with different characters
what is Unicode?
a character set designed to solve the problem of ASCII’s limited character set
uses a varying number of bits allowing for over 1 million different characters
many characters are yet to be allocated
enough capacity to represent different languages, symbols, and emojis