Data Types

Cards (8)

  • Two methods to represent negative numbers in binary, Sign and Magnitude and Twos Complement
  • In sign and magnitude, the most significant bit is used as a sign bit, meaning the binary value is used to tell us if the number is positive or negative
    0 = positive
    1 = negative
    Highest value that can be stored it only 127, but can store down to -127
  • In Twos Complement, the most significant but becomes the same value, but negative (e.g. -128)
    1. Write out positive version of the number
    2. Copy out that binary digit from the right side up to and including the first 1
    3. For the rest of the number, invert all the digits you write
    The highest value that can be stored is 127, the lowest is -128
  • Two methods of storing fractional numbers in binary, Fixed-point binary and Floating-point binary
  • Fixed-point binary means the decimal point is in a fixed position in the binary number
    This requires less bits of data to store, but some numbers, such as 1/3 cannot be stored this way
  • Floating-point is a more accurate way of storing numbers in binary
    8 bits are still used but the decimal point floats around, changing the value of the bits
    To store where the decimal point actually is, the binary number is split into two parts, the mantissa (number itself) and exponent (where the decimal point is)
    Positive exponent = decimal point moves to the right
    Negative exponent = decimal point moves to the left
  • In floating-point binary, there is more than one way to store some numbers
    We need a consistent way to store the same numbers so all computers read numbers the same, so we normalise the number
    Positive numbers start with 01
    Negative numbers start with 10
  • To add or subtract floating-point numbers together, convert them to normal binary and add or subtract them from there. The result cannot be converted back into floating-point though so a loss in accuracy occurs