1.4.1 - Data Types Flashcards
What is an integer?
An integer is a whole number. It can be positive or negative.
eg. 6, 47238, -12, 0, 15
What is a real/float?
A real number is a number with a fractional part.
eg. -71.5, 5.01, -80.8, 15.0
What is a character?
A single symbol used by a computer.
eg. A, Z, (, #
What is a string?
A string is a collection of characters.
eg. ‘Hello, world!’, 07789
What is a boolean value?
A true or false value.
Convert the binary number 1101 into denary.
13
Convert the denary value 47 into binary.
0010 1111
Add these two binary numbers: 1011 and 1110.
11001.
Add the two binary numbers: 0011 0011 and 1001 0110.
1100 1001
Two equal (unsigned) integers, shown below, are added together. Calculate the result, showing your working. [2 marks]
00010101
00010101
0010 1010
What are the two ways of expressing negative numbers in binary?
Sign and Magnitude.
Two’s Complement.
How does sign and magnitude work?
The leftmost bit indicates the sign of the binary value.
A 0 represents a positive number and a 1 represents a negative number.
Convert the denary number -8 into an 8-bit sign and magnitude number.
1000 1000
Show a representation of denary -119 in 8-bits using sign and magnitude. [1 mark]
1111 0111
How does two’s complement work?
The left-most significant bit is a negative number.
How do you convert to two’s complement?
Flip all of the bits in the positive version of the binary number and then add one.
Convert the denary number -8 to an 8-bit two’s complement binary number.
1111 1000
Show a representation of denary -119 in 8-bits using two’s complement. [1 mark]
1000 1001
Subtract 12 from 8 using two’s complement.
11100
What base is hexadecimal?
Base 16.
Convert the hexadecimal number A6 into denary.
166.
Convert the hexadecimal number B2 into binary.
1011 0010.
Convert the hexadecimal number B2 to denary.
178.
Convert the 10-bit mantissa and 6-bit two’s complement number into denary.
1100 1001 11 0001 01
50.4375
A computer represents floating point binary numbers using a 6-bit mantissa and a 4-bit exponent, both using two’s complement.
Add the following three numbers together and give the answer in the format described. [6 marks]
010100 0010
011000 0001
100010 0010
010000 1111
What does normalising a floating-point binary number allow for?
It makes sure the number is as precise as possible.
What does a normalised positive floating-point binary number start with?
01
What does a normalised negative floating-point binary number start with?
10
Normalise the following binary number.
000110100101 0101
0110 1000 0011
What must be the same to add floating-point binary numbers?
Their exponents.
Add the following floating-point numbers.
000100 0011
000101 0010
011010 0001
What is a shift used for in the manipulation of binary?
To multiply or divide a number.
Explain how, using bit shift, the unsigned binary number 00101100 can be divided by 4. [2 marks]
Shift right two places.
00001100 is shifted two places to the left.
Show the result.
Identify what arithmetic operation this shift is equivalent to. [2 marks]
0011 0000
Multiplying by 4.
An AND operation with the mask 10101010 is applied to the binary number 01010101.
Show the result. [1 mark]
0000 0000
An OR operation with the mask 10101010 is applied to the binary number 01010101.
Show the result. [1 mark]
1111 1111
Two floating point numbers are shown below. Calculate the answer of the second number subtracted from the first. You must show your working and ensure your answer is normalised. [5 marks]
01001100 0011 - 01001010 0010
01001110 0010