






























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An introduction to number systems, focusing on binary representation and its conversions to decimal and hexadecimal. It covers positional notation, common powers, binary to decimal and hex to decimal conversions, and the representation of binary numbers in hexadecimal format. The document also explains how to convert binary numbers to decimal and hexadecimal.
Typology: Study notes
1 / 38
This page cannot be seen from the preview
Don't miss anything!































The textbook uses subscripts to represent different bases (ie. A2F 16 , 953.78 10 , 1011.11 2 )
Special symbols can be used to represent the different bases. The default base will be decimal, no special symbol for base 10.
The ‘$’ will be used for base 16 ( $A2F) Will also use ‘h’ or ‘H’ at end of number (A2Fh, A2FH)
The ‘%’ will be used for base 2 (%10101111)
Divide Number N by base R until quotient is 0. Remainder at EACH step is a digit in base R, from Least Significant digit to Most Significant digit.
Convert 53 to binary 53/2 = 26, rem = 1 26/2 = 13, rem = 0 13/2 = 6, rem = 1 6 /2 = 3, rem = 0 3/2 = 1, rem = 1 1/2 = 0, rem = 1
53 = % 110101 = 1x2^5 + 1x2^4 + 0x2^3 + 1x2^2 + 0x2^1 + 1x2^0 = 32 + 16 + 0 + 4 + 0 + 1 = 53
Least Significant Digit
Most Significant Digit
Most Significant Digit (has weight of 2^5 or 32). For base 2, also called Most Significant Bit (MSB). Always LEFTMOST digit.
Least Significant Digit (has weight of 2^0 or 1). For base 2, also called Least Significant Bit (LSB). Always RIGHTMOST digit.
Each Hex digit represents 4 bits. To convert a Hex number to Binary, simply convert each Hex digit to its four bit value.
A2Fh = % 1010 0010 1111
345h = % 0011 0100 0101
Binary to Hex is just the opposite, create groups of 4 bits starting with least significant bits. If last group does not have 4 bits, then pad with zeros for unsigned numbers.
% 1010001 = % 0101 0001 = 51h
Padded with a zero
Recall than N binary digits (N bits) can represent unsigned
integers from 0 to 2N-1.
4 bits = 0 to 15 8 bits = 0 to 255 16 bits = 0 to 65535
Besides simply representation, we would like to also do arithmetic operations on numbers in binary form. Principle operations are addition and subtraction.
The rules for binary arithmetic are:
0 + 0 = 0, carry = 0 1 + 0 = 1, carry = 0 0 + 1 = 1, carry = 0
1 + 1 = 0, carry = 1
The rules for binary subtraction are:
0 - 0 = 0, borrow = 0 1 - 0 = 1, borrow = 0 0 - 1 = 1, borrow = 1
1 - 1 = 0, borrow = 0
Borrows, Carries from digits to left of current digit. Binary subtraction, addition works just the same as decimal addition, subtraction.
Decimal
900
899 0-1 = 9; with borrow of 1 from next column 0 -1 (borrow) - 0 = 9, with borrow of 1 9 - 1 (borrow) - 0 = 8. Answer = 899.
Binary
% 100
011 0-1 = 1; with borrow of 1 from next column 0 -1 (borrow) - 0 = 1, with borrow of 1 1 - 1 (borrow) - 0 = 0. Answer = % 011.
3Ah
62h
A+8 = 2; with carry out of 1 to next column
1 (carry) + 3 + 2 = 6. answer = $ 62.
3Ah = 3 x 16 + 10 = 58 28h = 2 x 16 + 8 = 40 58 + 40 = 98
62h = 6 x 16 + 2 = 96 + 2 = 98!
Decimal check.
With paper and pencil, we can write a number with as many digits as we want:
1,027,80,032,034,532,002,391,030,300,209,399,302,992,092,
A microprocessor or computing system usually uses FIXED PRECISION for integers; they limit the numbers to a fixed number of bits:
$ AF4500239DEFA231 64 bit number, 16 hex digits $ 9DEFA231 32 bit number, 8 hex digits $ A231 16 bit number, 4 hex digits $ 31 8 bit number, 2 hex digits
High end microprocessors use 64 or 32 bit precision; low end microprocessors use 16 or 8 bit precision.
In this class we will use 8 bit precision most of the time, 16 bit occasionally.
Overflow occurs when we add or subtract two numbers, and the correct result is a number that is outside of the range of allowable numbers for that precision. We can have both unsigned and signed overflow (more on signed numbers later)
8 bits -- unsigned integers 0 to 2^8 -1 or 0 to 255.
16 bits -- unsigned integers 0 to 2^16 -1 or 0 to 65535