CS123

Cards (117)

  • Binary number system
    A system of counting using only 0 and 1
  • Binary number system
    • Power of 2s
    • Versus decimal number system (power of 10, 0-9 digits)
  • Why computers use binary
    Due to physical limitations of the computer
  • Everything a computer does comes down to microtransistors
  • Numeric representation

    • Decimal numbers
    • Binary numbers
  • Decimal numbers
    Represented using decimal arithmetic
  • Binary digit (bit)
    • The smallest unit of information used in computing and digital communications
    • Can have only one of two values, typically represented as 0 or 1
    • In electronic circuits, these two values are usually represented by the presence or absence of an electrical signal, respectively
  • Word
    • The natural unit of data that a particular computer's central processing unit (CPU) can handle in a single operation
    • Size of a word can vary depending on the architecture of the computer system, but it is typically a multiple of the number of bits that can be processed by the CPU's registers at one time
  • Word
    • Affects the way that data is stored and manipulated in memory
    • In some contexts, the term "word" may be used more broadly to refer to any fixed-size unit of data, regardless of whether it matches the CPU's natural word size
  • Byte
    • A unit that represents 8 bits, 1 character or number
    • 1 byte = 8 bits
    • 1 bit can be represented in 2 ways, i.e. combination of 8 bit patterns into 1 byte enables the representation of 2^8 = 256 types of information
    • Using a 1-byte word, 256 different characters can be represented – sufficient for most Western character sets
    • However, the number of kanji (Chinese characters) amounts to thousands of different characters, hence a 1-byte word system is insufficient
    • Two bytes are connected to obtain 16 bits, 2^16 = 65,536
  • Number systems
    • Decimal (base 10)
    • Binary (base 2)
    • Octal (base 8)
    • Hexadecimal (base 16)
  • Hexadecimal
    0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F where A=10, B=11, C=12, D=13, E=14, F=15
  • All digital data is represented and processed using different number systems, particularly the binary number system
  • The decimal system is widely used in everyday life, including in financial transactions, measurements, and scientific calculations. It is also the most commonly used number system in computing, as most programming languages and computer hardware use the decimal system to represent numeric values
  • Other number systems, such as the octal and hexadecimal systems, are used in computer programming to represent and manipulate data more efficiently
  • The true value of numbers are the same, the representation of numbers vary
  • Numeric data representation
    • Binary
    • Decimal
    • Octal
    • Hexadecimal
  • Number systems conversions
    1. Decimal to Binary
    2. Binary to Decimal
    3. Decimal to Octal
    4. Octal to Decimal
    5. Decimal to Hexadecimal
    6. Hexadecimal to Decimal
    7. Binary to Octal
    8. Octal to Binary
    9. Binary to Hexadecimal
    10. Hexadecimal to Binary
  • Number systems conversions (with fractions)
    1. Decimal to Binary
    2. Binary to Decimal
    3. Decimal to Octal
    4. Octal to Decimal
    5. Decimal to Hexadecimal
    6. Hexadecimal to Decimal
    7. Binary to Octal
    8. Octal to Binary
    9. Binary to Hexadecimal
    10. Hexadecimal to Binary
  • Binary fraction to decimal
    Each binary digit uses the base-2 numbering system
  • Binary addition
    1. Rule 1: 0 + 0 = 0
    2. Rule 2: 1 + 0 = 1
    3. Rule 3: 1 + 1 = 0 with a carry of 1
  • Binary subtraction
    1. Rule 1: 0 from 0 = 0
    2. Rule 2: 1 from 1 = 0
    3. Rule 3: 0 from 1 = 1
    4. Rule 4: 1 from 0 - put down 1, and then change the numbers in the top row until you change a 1 to a 0
  • Binary subtraction
    • Example: 1010 - 0111 = 11
  • The problem in the above example is simple because all you have to do is subtract the digit 1 from another digit 1 just as you do in the decimal system. However, when you subtract a larger digit from a smaller digit you have to "borrow" from the next column of digits.
  • "Borrowing" in the binary system tends to be confusing when you first start because we are so used to the decimal system. But, by carefully applying the rules given below, you can perform subtraction without errors.
  • Binary Subtraction
    Apply these rules by solving the problem in the example below step by step
  • Rule 1
    • The column on the far right shows that a 1 must be subtracted from a 0. This means you must borrow 1 from the second column.
  • Rule 2
    • Following rule 4, put down a 1 and change digits in the top row until you change a 1 to a 0.
  • Rule 3
    • The same problem now exist in the second column, so apply rule 4 again
  • Rule 4
    • In the third column apply rule 2
  • Now check your answer using addition just as you do in the decimal system
  • Addition and subtraction of hexadecimal numbers
  • Addition
    Performed starting at the lowest (first from the right) digit
    A carry to the upper digit is performed when the result is higher than 16
  • Subtraction
    Performed starting at the lowest (first from the right) digit
    A borrow from the upper digit is performed when the result is negative
  • Hexadecimal Addition
    • D + 7 = 4 (carried 1)
    1 + 8 + 1 = A
    A + B = 5 (carried 1)
    Result: (15A4)16
  • Hexadecimal Subtraction
    • 3 - 4 = F (borrowed 1 from D)
    C - 7 = 5
    6 - 1 = 5
    Result: (55F)16
  • 9's complement
    The result of subtracting each digit of a numeric value from 9
  • 10's complement
    The result of subtracting each digit of a numeric value from 9, then adding 1 to the rightmost digit
  • 1's complement
    The result of subtracting each bit of a binary number from 1
  • 2's complement

    The 1's complement plus 1