Integer representation and arithmetic pt1 Flashcards
What is a bit
A bit is a single binary digit, i.e., 0 or 1
What is a byte
A byte is an 8-element sequence of bits
What is a word
A word is a w-element sequence of bits
How does binary relate mathematically to integers
Mapping representation
What is little-endian ordering for bit sequences?
Least sig value stored first
What is big-endian ordering?
Which bit-sequence ordering is used most often? And why?
Little-endian (right-to-left)
Because it makes it such that the least sig bit is at the start (great for operating on it)
How do single binary operators apply to a string of bits
Applies to each element (eg not)
How do multi-binary operators (eg: AND OR XOR etc.) apply to two strings of bits
Applies to each element combined (make sure to pad with zeros on sig side)
What is the Hamming weight of a string of bits
What is the Hamming distance of two strings of bits
How does base expansion of a string of digits work
Multiply by base to the power of index (in little endian). Eg 2^0 2^1 etc.
How to convert between hexadecimal string and a binary string
Each hex character represents 4 bits so can expand
How does a binary left (or right) shift work
For left shift multiply by 2^y (or inverse for right shift)
How does the sign magnitude approach work
- 1st bit is reserved for the sign
- Means that there is pos and neg zero
- Smaller range than twos-compliment