Section 6, 7, 8 Data Types Flashcards
Integer
● A whole number
● Zero is an integer
● Negative numbers are integers
● Can’t have a fractional part
● Useful for counting things
Real
Positive or negative numbers
Can, but do not necessarily, have a fractional
part
Useful for measuring things
All integers are real numbers
Character
● A single symbol used by a computer
● The letters A to Z
● The numbers 0 to 9
● Symbols like %, £
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 type
Boolean
● Restricted to True and False
● Useful for recording data that can only take two
values
Least significant bit
furthest to right
most significant bit
furthest to left
-ve number sign and magnitude
Leading 1 is like adding a - sign
0 is a + sign
Two’s Complement
● Has the added advantage of making binary arithmetic with negative numbers much
more simple
● Works by making the most significant bit negative
● Converting to two’s complement is as simple as flipping all of the bits in the positive
version of a binary number and adding one
Two’s complement, subtraction in binary
● Two’s complement makes subtraction in binary easy
● 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
Floating point numbers can be split into two parts:
○ Mantissa
○ Exponent
Normalisation
● Maximises precision in a given number of bits
● To normalise a binary number:
○ Adjust the mantissa so that it starts 01 for a positive number of 10 for a
negative number
Character Sets for Representing Text
● A published collection of codes and corresponding characters
● Can be used by computers for representing text
● Two widely used character sets are ASCII and Unicode
ASCII
American Standard Code for Information Interchange
● 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
ASCII
American Standard Code for Information Interchange
● 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