Beyond Base : Non-decimal Based Number Systems What is the decimal based number system? How do other number systems work (binary, octal and hex) How to convert to and from nondecimal number systems to decimal math Base unique symbols are used to represent values : What Is Decimal? The number of digits is based on the number of digits The largest decimal value that can be represented by a single decimal digit is = base() - Table Of Values Base two value value Employs two unique symbols ( and ) Largest decimal value that can be represented by binary digit = = base() - Why Bother With? Representing Information: ASCII Representing information ASCII (American Standard Code for Information Interchange) Unicode It's the language of the computer Decimal - ASCII Invisible (control characters) Punctuation, mathematical operations Characters - Comparators and other miscellaneous characters : ;? @ - Alphabetic (upper case A - Z) More miscellaneous characters [ \ ] ^ _ ' Alphabetic (lower case a - z) - More miscellaneous characters { } ~ DEL
Representing Information: ASCII () Uses bits to represent characters Max number of possibilities = = characters that can be represented Representing Information: Unicode Uses bits (or more) to represent information Max number of possibilities = = characters that can be represented (more if more bits are used) e.g., 'A' is in decimal or in binary. In memory it looks like this: Computer Programs is the language of the computer Base eight Octal Employs eight unique symbols ( - ) ) A programmer writes a computer program ) The compiler translates the program into a form that the computer can understand ) An executable program is created. Anybody who has this executable installed on their computer can then run (use) it. Largest decimal value that can be represented by octal digit = = base() - Table Of Octal Values Uses Of Octal (Assembly Language) Octal value Octal value Machine Octal PDP - assembly language value language MOV #, R MOV (R), R Example from Introduction to the PDP- and its Assembly Language by Frank T.
Hexadecimal (Hex) Table of Hex Values Base sixteen Employs sixteen unique symbols (, followed by A - F) Largest decimal value that can be represented by hex digit = Hexadecimal value Hexadecimal value A B C D E F Uses Of Hexadecimal (Assembly Language) Summary (Decimal,, Octal, Hex) Decimal Octal Hex Decimal Octal Hex Machine Hexadecimal X assembly language value language C MOV.B D, (A)+ E BRA NEXT A B C D E F Example from Family Assembly Language by Clements A. High Vs. Low Level Overflow: A Real World Example People languages E.g., English, French, Spanish, Chinese, German etc. High level You can only represent a finite number of values High level programming language E.g., Pascal, Java, C++ Low level programming language Assembly Machine language Computer hardware Low level
Overflow: Occurs when you don't have enough bits to represent a value ( wraps around to zero) ( bit) Value ( bits) Value : : : : Value ( bits) Base N Employs N unique symbols Arbitrary Number Bases Largest decimal value that can be represented by digit = Base (N) - : : Converting Between Different Number Systems to/from octal to/from hexadecimal Octal to/from hexadecimal Decimal to any base Any base to decimal To Octal binary digits equals one octal digit (remember =) Form groups of three starting at the decimal For the integer portion start grouping at the decimal and go left For the fractional portion start grouping at the decimal and go right e.g. =???. Octal To octal digit equals = binary digits Split into groups of three starting at the decimal For the integer portion start splitting at the decimal and go left For the fractional portion start splitting at the decimal and go right To Hexadecimal binary digits equals one hexadecimal digit (remember =) Form groups of four at the decimal For the integer portion start grouping at the decimal and go left For the fractional portion start grouping at the decimal and go right e.g.. =??? e.g.,. =???..
Hexadecimal To hex digit equals = binary digits Split into groups of four starting at the decimal For the integer portion start splitting at the decimal and go left For the fractional portion start splitting at the decimal and go right e.g., A. =??? Convert to binary first! e.g., to???. Octal To Hexadecimal. Octal To Hexadecimal Hexadecimal To Octal Convert to binary first! e.g., to??? e.g., to??? Add any leading zeros that are needed (in this case two). Regroup in groups of... e.g., to???.. Hexadecimal To Octal Add any leading zeros that are needed (in this case one). Regroup in groups of Decimal To Any Base Split up the integer and the fractional portions ) For the integer portion: a. Divide the integer portion of the decimal number by the target base. b. The remainder becomes the first integer digit of the number in the target base. c. The quotient becomes the new integer value. d. Divide the new integer value by the target base. e. The new remainder becomes the second integer digit of the converted number. f. Continue dividing until the quotient is less than the target base and this quotient becomes the last integer digit of the converted number.
Decimal To Any Base () ) For the fractional portion: a. Multiply by the target base. b. The integer portion (if any) of the product becomes the first rational digit of the converted number. c. The non-rational portion of the product is then multiplied by the target base. d. The integer portion (if any) of the new product becomes the second rational digit of the converted number. e. Keep multiplying by the target base until either the resulting product equals zero or you have the desired number of places of precision. e.g., to??? / : q = r = / : q = r = /: q = r = Decimal To Any Base (). Stop dividing! (quotient less than target base) Any Base To Decimal Multiply each digit by the base raised to some exponent and sum the resulting products. - - - Position of digits i.e. d d d d. d d d b Number to be converted Base = b Value in decimal = (digit*b ) + (digit*b ) + (digit*b ) + (digit*b ) + (digit*b - ) + (digit*b - ) + (digit*b - ) e.g., to??? Any Base To Decimal () Position of the digits. Number to be converted Base = Value in decimal = (* ) + (* ) = (*) + (*) = + = The value of this exponent will be determined by the position of the digit. Addition In : Five Cases Addition In : Five Cases () Case : sum =, no carry out + Case : sum =, no carry out + Case : Sum =, Carry out = + + = (in decimal) = (in binary) + Case : sum =, no carry out + Case : sum, carry out = + = (in decimal) + = (in binary)
Subtraction In ( cases) You Should Now Know Case : - Case : - Case : - Case : - The amount that you borrow equals the base Decimal: Borrow : Borrow What is meant by a number base. How binary, octal and hex based number systems work and what role they play in the computer. What is overflow, why does it occur and when does it occur. How to/from convert between non-decimal based number systems and decimal. How to perform simple binary math (addition and subtraction).