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