Binary Representation Flashcards
Bit
Bit: “Binary digiT,” a basic unit of information in a computer
○ 1 bit = a bit
○ 4 bits = a nibble
○ 8 bits = a byte
Digital
finite number of symbols (opposite is “analog” i.e. continuous)
Signed Magnitude
MSB tells sign of number. No further adjustments
001 = 1
101 = -1
Issue:
- two numbers for 0
- arithmetic not straight forward. Does not work.
1C
Flip all digits, to obtain negative of unsigned number
001 = 1
110 = -1
issue:
- two numbers for 0
- Hardware to perform addition is tricky to implement
2C
1C + 1 to obtain negative of unsigned number.
Alternative approach: copy bits from right to left up to and including the first “1” and flip remaining bits
Advantage:
- only one representation for zero
- computer can add positive and negative numbers together
Floating Point
○ sign, fraction, and exponent
○ N = (-1) S × 1.fraction × 2^(exponent-127)
1__10000001__10101000000000000000000
S__Exponent__Fraction
Unsigned overflow
Operation results goes beyond the width of memory location in a computer/ width of machine
Signed overflow
positive + positive number -> negative
negative + negative number -> positive
ASCII - Size
2^7 = 128 combinations
UNICODE - Size
2^32 combinations
How do calculations with fractions in binary work
2C addtion and stubtraction still work. To do this, allign binary points
Word
bits computer can process in one operation
Multiplication of two n bit numbers. Result how many bits
2n
Addition of two n bit numbers. Result how many bits
up to n+1
Largest and smallest number that can be represented with n bits in 2C
Largest: 2^(n-1)-1
Smallest:-2^(n-1)