Data Representation Flashcards
What are ordinal numbers?
Numbers used for explaining the position of a number in a well ordered set
What numbers are used for counting and measurement?
- Natural numbers for counting
- Real numbers for measurement
What is a bit? What is a byte?
The most fundamental unit of information. 8 bits make up a byte
How can you tell how many numbers can be represented by a binary number? What is the maximum value?
- 2^n where n is the number of bits used
- 2^n - 1 is the maximum value
Binary prefixes
Kibi - 2^10
Mebi - 2^20
Gibi - 2^30
Tebi - 2^40
Decimal prefixes
kilo - 10^3
mega - 10^6
giga - 10^9
tera - 10^12
Why is hexadecimal used?
- Easy to convert from binary
- Easily read by humans
- More concise
Where is hexadecimal used?
memory addresses, error message codes, HTML colour codes
What is pure binary?
Unsigned binary
How does binary shift work?
Shift to right is double, shift to left is half
Describe signed binary numbers.
- Sign is represented through MSB (most significant bit)
- 1 in sign bit represents a negative number, 0 is positive
- Range is same as unsigned binary
How to convert from binary to hexadecimal?
Consider each nibble and convert to hexadecimal equivalent 0 to F
How to use two’s complement to find negative binary numbers? How is a carry bit used?
- write number out in binary
- if number is positive, add a sign bit of 0 and leave it
- if negative, change to 1’s complement (switch all 0’s and 1’s) AND add 1 (ignoring carry bit at the sign bit)
- carry bit is used for checking overflow
What is an overflow error? What is an underflow error?
- Overflow: a number is too large to represent within the number or bits available
- Underflow: a number is too small e.g. 0.000001 to be represented in number of bits available
- store overflow bits elsewhere to prevent error
- set flag bit to indicate error
How to multiply binary numbers? How to subtract binary numbers?
Multiplication:
- convert to 2^n and perform n shifts
- do long multiplication
Subtraction:
- convert to two’s complement
- add together