Unit 6 : Data Types Flashcards
What is an integer
● A whole number
● Zero is an integer
● Negative numbers are integers
● Can’t have a fractional part
● Useful for counting things
What is a real
● 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
What is boolean alegbra
● Restricted to True and False
● Useful for recording data that can only take two value
how would you represent positive integers in binary
● A single binary digit is called a bit
● Eight binary digits can be combined to form a byte
● Half a byte (four bits) is called a nybble
● The least significant bit of a binary number is the one furthest to the right
● The most significant bit is furthest to the left
What are the 4 simple rules to binary addition
- 0 + 0 + 0 = 0
- 0 + 0 + 1 = 1
- 0 + 1 + 1 = 10
- 1 + 1 + 1 = 11
What is sign magnitude when talking about representing negative numbers in binary
● The equivalent of adding a + or - sign in front of a number
● A leading 1 is added for a negative number
● A leading 0 is added for a positive number
What is a two’s compliment when talking about representing negative numbers in binary
● 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
What is 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
What is a character set
● 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
What is 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
What is Unicode
● Solves the problem of ASCII’s limited character set
● Uses a varying number of bits allowing for over 1 million different characters
● Many characters have yet to be allocated
● Enough capacity to represent a wealth of different languages, symbols, and emoji