1.4.1

Cards (42)

  • When writing a program, it's essential to make sure data is being stored with the right data type, so that the right operations can be performed on it
  • Integer
    A whole number
  • Integers
    • 6
    • 47238
    • -12
    • 0
    • 15
  • Real
    Positive or negative numbers which can, but do not necessarily, have a fractional part
  • Real numbers
    • 0
    • -71.5
    • 5.01
    • -80.8
    • 15
  • Character

    A single symbol used by a computer
  • Boolean
    Values are restricted to True and False
  • Boolean
    • True
    • False
  • Bit
    A single binary digit
  • Byte
    Eight binary digits
  • Nybble
    Half a byte (four bits)
  • Least significant bit
    The bit furthest to the right
  • Most significant bit
    The bit furthest to the left
  • Converting decimal to binary
    1. Find the largest power of two smaller than the number
    2. Write out place values in powers of two up to this power
    3. Place a 1 or 0 in each position so the total adds up to the original number
  • Binary addition
    1. 0 + 0 + 0 = 0
    2. 0 + 0 + 1 = 1
    3. 0 + 1 + 1 = 10
    4. 1 + 1 + 1 = 11
  • Sign magnitude
    Represents negative numbers by adding a leading 1 for negative and 0 for positive
  • Two's complement

    Represents negative numbers by flipping all bits and adding 1
  • Subtracting in binary using two's complement
    Subtracting a number is the same as adding the negative of that number
  • Hexadecimal
    A base 16 number system that uses digits 0-9 and A-F
  • Hexadecimal numbers
    • 4E7F
  • 4E7F = 20095 in decimal
    • 12
    10100 in binary
  • Minimum number of bits required to represent -12
    • Five
  • Adding two's complement numbers
    1. Convert to binary
    2. Add using same technique
    3. Read off result
  • The calculation -16 + 8 + 4 = -4 is correct
  • Hexadecimal
    Base 16 number system
  • Hexadecimal digits

    • 0-9
    • A-F
  • Converting hexadecimal to decimal
    1. Convert each hexadecimal digit to decimal
    2. Combine using place values
  • Converting hexadecimal to binary
    1. Convert each hexadecimal digit to decimal
    2. Convert decimal to binary nybble
    3. Combine binary nybbles
  • Converting hexadecimal to decimal
    1. Convert to binary first
    2. Then convert binary to decimal
  • Floating point binary

    Like scientific notation, with mantissa and exponent
  • Floating point number structure
    • Sign bit
    • Mantissa
    • Exponent
  • Converting floating point binary to decimal
    1. Convert sign bit
    2. Convert mantissa to decimal
    3. Convert exponent to decimal
    4. Combine to get final value
  • Normalising floating point binary
    1. Adjust mantissa to start 01 or 10
    2. Adjust exponent accordingly
  • Adding floating point binary numbers
    1. Ensure exponents are the same
    2. Add mantissas
    3. Normalise result
  • Subtracting floating point binary numbers
    1. Ensure exponents are the same
    2. Convert subtrahend mantissa to two's complement
    3. Add mantissas
    4. Normalise result
  • Logical shift
    Shifting bits left or right, adding/removing leading/trailing zeros
  • Logical shift left
    Multiplies by 2 to the power of the number of places shifted
  • Mask
    Applying a logic gate (AND, OR, XOR) to combine two binary numbers
  • Character set

    Published collection of codes and corresponding characters for representing text