
Class 2: Numbering Why different Systems numbering systems? • Numbering systems – Decimal – Binary – Hexadecimal • Hexadecimal to Binary Conversion • Data Organization • Homework 1 -> due a week from today! Different ways of Decimal System representing the same (a review) value • Commonly used by: people! • Each digit represents a power of 10 • Digits go from 0 to 9 • Also known as Base 10 • Example: 123 = • How many frogs? 10 If moving to the right of the decimal point, powers decrease: 2.4510 = 1 Binary System, Binary System continued • Used by: computer internal • For convenience, a numeric representation. value can be assigned to each • In binary, each digit represents bit position: a power of 2. x7 x6 x5 x4 x3 x2 x1 x0 • Binary numbers are made entirely of 0 and 1. • Also known as Base 2. • Binary digits are also known as bits. Binary to Decimal Decimal to Binary Conversion Conversion: Method 1 • multiply the digit by 2 to the • Divide by Decreasing Powers of power of the bit position 2 • Examples: 1012 = Example: Converting 7610 to Binary 110010102 = 2 Decimal to Binary Hexadecimal System Conversion: Method 2 • Disadvantage: need to know • Used by: Debug utility. the powers of two • Also used as a more compact • Alternative: repeatedly divide way to represent numbers rather by 2 than binary. • In hexadecimal (or hex), each -- picture from Irvine, p 575 digit represents a power of 16. • Digits are 0 to 9 and A to F. • Hexadecimal numbers are denoted by the number, followed by an H or h. Decimal to Hex Hex to Decimal Conversion Conversion • A good method is to repeatedly • Convert each digit to decimal. divide by 16. • Multiply the digit by 16 to the • Example: Converting 15,26810 power of the bit position. to hexadecimal • Example: 3BA4h = 3 Converting between Hex Binary/Hexadecimal and Binary Conversion Table • Each hexadecimal digit • from AoA represents four binary digits. • Lookup tables (or, better yet, memorized bit patterns) can be used to do the conversions. • No multiplication or addition required! Binary to Hexadecimal Hexadecimal to Binary • Break the number up into four • Convert each hex digit into the digit (bit) pieces, starting from four digit (bit) binary the least significant (right-most) representation bit • Example: • Convert each four digit segment 8A2640 into the corresponding hexadecimal digit • Example: 10101011100101111000011011100101 4 Data Organization Bytes Bit numbering in a byte: • Computers work with groups of bits (binary digits) 7 6 5 4 3 2 1 0 • Common groups of bits are: – Single bits – Groups of 4 bits – nibbles High Order Low Order – Groups of 8 bits – bytes Nibble Nibble – Groups of 16 bits – words – Groups of 32 bits – double words A byte can represent values: 0..255 (unsigned) -128..+127 (signed) or, special data types that require no more than 256 different values Words Bit numbering in a word: 151413 12 11 10 9 8 7 6 5 4 3 2 1 0 High Order Low Order Byte Byte A word can represent values: 0..65,535 (unsigned) -32,768..+32,767 (signed) 5.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages5 Page
-
File Size-