1.4.1 Data Types Flashcards
What is a bit?
Either a 1 or 0
We use bits to represent the two electronic states: on and off.
How many bits are in a byte?
8 bits in a byte
How many bits are in a nibble?
4 bits in a nibble
How many values can be represented with n bits?
2^n
How many bytes are in a kibibyte?
1024
What is the power of kibi?
2^10
What is the power of mebi?
2^20
What is the power of gibi?
2^30
What is the power of tebi?
2^40
What is the power of pebi?
2^50
What is the power of exbi?
2^60
What is the power of zebi?
2^70
What is the power of yobi?
2^80
What is a character set?
A collection of characters, each assigned a unique binary value
How many bits does ASCII use per character?
7
How many bits does extended ASCII use per character?
8
How many bits does UNICODE use to represent a character?
16
What’s the difference between UNICODE and ASCII?
ASCII only represents english characters whereas UNICODE represents all symbols even from other languages
What is a real/float?
Used to store decimal numbers and to store very large/small values
What is a character/char?
A single letter, number or special characters typically represented in ASCII
What is a string?
A collection of characters. Anything enclosed in quotation marks is a string
What is boolean/bool?
A boolean variable can only take the value TRUE or FALSE
What is an integer?
A whole number
What is casting?
The process of changing one data type into another
What are the bases of denary, binary and hex?
Denary - 10
Binary - 2
Hex - 16
Why use hex over binary?
More likely to make mistakes when writing in binary than hex
Easier to work with
How does hex represent numbers?
Uses 0-9 to represent 0-9
Uses letters A-F to represent 10-15
Each part is represented by a nibble ( 4 bits )
Convert 229 to hex
1110 0101
14 5
E5
Convert F3 to denary
1111 0011
243
How does sign and magintude work in binary?
The most signifcant bit represents whether the number is positive or negative
1 is negative
0 is positive
What are 2 problems with sign and magnitude?
Addition of numbers is trickier for the computer
Reduced number of bits avaible for represent our number
Max number that we can make with 8 bits is 127
What is two’s complement?
A way of storing positive and negative numbers by the most significant bit taking the negative value of itself.
What are the 2 methods of writing in twos complement?
1 - write the positive version of the number, flip the bits and add one
2 - add the numbers, usually using the MSB as a negative version of itself ( for example -128 ), and keep adding positive numbers until its the correct number
What is a left shift?
All the bits are shifted to the left
For every place value shifted, the value is doubled
What is a right shift?
All the bits are shifted to the right
For every place value shifted, the value is halved.
Why are floating-point numbers normalised?
To ensure that they are as precise as possible in a given number of bits
How do you normalise a binary number?
Example:
00101 000
Remove extra zeros from the front (only 1 is allowed) and buff the back of the mantissa. Decrease the exponent by 1
01010 111
How would you convert 1.75 to floating point binary?
Write out the fixed point: 01.11
Move the decimal point: 0.111
The mantissa: 01110
The exponent: 0001
All together: 011100001
What happens when you increase the size of the exponent?
Increases the size of the number that can stored
What happens when you increase the size of the mantissa?
Increases the precision of the number that can be stored