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.