ECE 252 Week 2
Twos complement (say 4 bit)
0 in the first bit is positive, 1 in the first bit is negative. The smallest is 1000 (-8) and the largest is 0111 (7). The range is [-(2^(k-1)), (2^(k-1)-1)]. There is only one representation for zero: 0000. Negative numbers are the twos complement of the positive number
Sign magnitude (say 4 bit)
0 in the first bit is positive, 1 in the first bit is negative. The smallest is 1111 (-7) and the largest is 0111 (7). The range is [-(2^(k-1)-1), (2^(k-1)-1)]. There are two representations for zero: 1000 and 0000.
Hexadecimal
A base-16 number system that uses sixteen distinct symbols 0-9 and A-F to represent numbers from 0 to 15. It makes reading a binary-like number much easier.
Adding two numbers in twos complement representation
Add the two binary numbers normally, but ignore the final carry (carry-out).
Radix
Base of a number system. Ex: radix of hexadecimal is 16.
Overflow for twos complement:
Can only occur if the two numbers being added have the same sign. Overflow has occurred if two numbers with the same sign are added and you get a number with the opposite sign.
Universal way to convert from decimal to a different base.
Divide by the base. The remainder each time is the result for that place and the quotient is the next number to be divided.
Sign extension (SEXT) 2s complement binary numbers
Duplicate the sign bit as many times as needed.
Negating/taking twos complement of twos complement representation
Flip all of the bits and add one to the result. EX: 01101 (13) --> 10011 (-13)
Sign extension (SEXT) sign-magnitude binary numbers
Keep the sign bit the same and add zeros in between the sign bit and the number.
Can you add a positive and negative number in sign-magnitude representation
No.
Presence of voltage is ____ and absence of voltage is ____
Presence of voltage is 1 and absence of voltage is 0. It is only differentiated between high and low.
The max digit value of a number system with a given radix is
R-1. Example, the max digit for base 10 is 9.
In binary, multiplying a number by 2^N is the same as:
Shifting the number to the left N times. This is similar to multiplying by powers of ten in base ten. This also works for dividing.
Sign extension (SEXT) unsigned binary numbers
Simply add zeros in front of the number
Unsigned integers (say 4 bit)
Smallest is 0000 (0), largest is 1111 (15). The range is [0, (2^k) -1]
"Faster" way to convert from decimal to binary
Start with the most significant digit. If the place value fits within the number, write down either one and subtract the number from the total. Repeat until the result is 0.
Converting between binary and hex and vice versa
Substitute the groups of four binary digits for one hexadecimal digit.
Converting between binary and octal and vice versa
Substitute the groups of three binary digits for one octal digit.
Arithmetic and Logic Unit (ALU) simple idea
The ALU is used for addition and subtraction. It adds two bit patterns.
Radix point
The dot that separates the whole part from the fractional part in a real number in any base.
Octal
The octal number system is base 8, using only digits 0 through 7.
Subtraction using borrowing in other number systems
Works just like base 10. Be careful to keep the "borrowed" numbers in the right base.
Addition in other number systems
Works just like base 10. Make sure to carry at the proper times.
Data type
a particular representation that has operations so a computer can operate on it
The most significant digit is the______
digit furthest to the left
The least significant digit is the_____
digit furthest to the right
Overflow (general concept)
occurs when the magnitude of the number is too large to be represented. The result will not be correct.
Converting between octal and hex
use binary as an intermediate
Value vs number
value is a particular quantity while a number is a way to represent value. For example, 3 (in base 10) and 011 (in base 2) have the same value but are different numbers.