Data Types Flashcards
What are the 5 primitive data types?
- integer
- real/floating point
- character
- string
- boolean
What is an integer?
- a whole number with no fractional/decimal parts
- Can be positive or negative
- useful for counting things
What is a real/floating point number?
- positive or negative number which can but don’t need a fractional part
- useful for measuring things
- all integers are real numbers
What is a character?
- a single symbol used by a computer
- Eg. The letters of the alphabet, numbers, special characters
What is a string?
- a collection of characters
- can store a single character or many characters in succession
- useful for storing text and phone numbers starting in 0 (normal integers or floating point would get rid of the starting 0)
What is a Boolean?
- values of this data type are restricted to True and False
- useful for storing data that can only take 2 values eg. the state of a power button
What is the human counting system?
Base 10 - denary
What is the computer counting system?
Base 2 - binary
A single binary digit is a …
Bit
8 binary digits combined is a …
Byte
4 binary digits combined is a …
Nybble
How do you convert from binary to denary?
- the least significant bit is the one furthest right
- The most significant bit is the one furthest left
- the value of the columns increase by a power of 2 each one you move further right
- if the column has a 1 in it counts the value of that column once, if there is a 0 don’t count it
- add the value of all the columns with a 1 in them to get the binary number in denary
How do you convert from denary to binary?
- find the largest power of 2 which is smaller than the number you are converting, the write out the binary place values up to this value
- subtract this value from the original value, then repeat the process until you have 0.
- Make sure all the binary bits with 1s add up to the original value
What are the binary addition rules?
0+0+0=1
0+0+1=1
0+1+1=10 (1 is carried to next column in column addition)
1+1+1=11 (1 is carried over to next column in column addition)
What are the binary addition rules?
0+0+0=1
0+0+1=1
0+1+1=10 (1 is carried to next column in column addition)
1+1+1=11 (1 is carried over to next column in column addition)
How would you represent a binary number as a whole number of bytes?
You would add leading 0’s (0’s in front of the actual number) - these don’t affect the value of the binary number
How do you do binary addition?
Do it like column addition - like up the 2 binary numbers in columns using 1s column to like them up and then apply binary addition rules
If there is a carry then put the carried one in small under the next column to the left
what are the basic binary subtraction rules?
0-0=1
1-0=1
1-1=0
0-1=1 (borrow 1 from the adjacent higher order digit)