• bit (b) is the smallest unit of data in a computer
  • Byte (B) is usually 8 bits
    • Nibble is 4 bits
  • octet is 8 bits
  • Word is the natural unit of data used by a particular processor design, (in our course, it is 32 bits=4 bytes)
    • Halfword is 16 bits
  • The least significant bit (LSb) is the bit position in a binary integer representing the binary 1s place of the integer.
  • The most significant bit (MSb) represents the highest-order place of the binary integer

Signed Number Representations

  • is the number of bits allocated to represent an integer

Unsigned Integer

  • range: to
  • If the number of bits is less than , 0s are added to the left of the binary integer so that there is a total of bits. If the number of bits is greater than , the integer cannot be stored. A condition referred to as overflow will occur. (and the computer keeps the rightmost n-bits, and drops the rest of leftmost bits)

Sign–magnitude

  • A signed number is represented by the bit pattern corresponding to the sign of the number for the sign bit (often the MSb, set to 0 for a positive number and to 1 for a negative number), and the magnitude of the number (or absolute value) for the remaining bits
  • range: to
  • Sign–magnitude has two representations of : 000...000 and 100...000
  • Overflow in sign-and-magnitude representationtodo

Ones’ complement

  • The ones’ complement of a binary number is obtained by inverting all bits in the binary representation of the number (i.e., changing all 0s to 1s and all 1s to 0s)
    • The name one’s complement comes from the fact that the sum of a binary number and its one’s complement is a string of all 1s (i.e., for an -bit number)
  • ones’ complement system (or ones’ complement arithmetic) (of bits) represents negative numbers using the one’s complement of their corresponding positive numbers.
    • It has two representations of : 000...000 and 111...111
    • Its range is to
  • The one’s complement addition of binary integers of bits each is performed as follows: (the sum must lie within the range to ; otherwise, overflow occurs)
    • The integers are added as if they were unsigned integers: .
    • If there is a carry out of the MSb, it is added to the LSb of the result (this is called an end-around carry). If this produces another carry out of the MSb, the process is repeated until there is no carry out of the MSb (the result is ).
    • The result is expressed in one’s complement representation.

Two’s complement

  • for taking the two’s complement of an integer in binary, we copy bits from the right until a 1 is copied, Then, we flip the rest of the bits.
  • An alternative way to take the two’s complement of an integer is to first take the one’s complement and then add 1 to the result
  • range: to
  • Storing an integer in two’s complement format
    • The absolute value of the integer is changed to an n-bit binary.
      • If the integer is positive or zero, it is stored as it is:
      • if it is negative, the computer takes the two’s complement of the integer and then stores it.
  • Retrieving an integer in two’s complement format If the leftmost bit is 1, the computer applies the two’s complement operation to the integer. If the leftmost bit is 0, no operation is applied

Comparison tables https://en.wikipedia.org/wiki/Signed_number_representations#Comparison_table

Real Numbers

Fixed-point representation

Floating-point representation

Signed binary numbers

4-bit

BinaryUnsignedTwo’s complementSign–magnitudeOne’s complement
00000000
00011111
00102222
00113333
01004444
01015555
01106666
01117777
10008-8-0-7
10019-7-1-6
101010-6-2-5
101111-5-3-4
110012-4-4-3
110113-3-5-2
111014-2-6-1
111115-1-7-0

8-bit

BinaryUnsignedTwo’s complementSign–magnitudeOne’s complement
000000000000
000000011111
01111110126126126126
01111111127127127127
10000000128-128-0-127
10000001129-127-1-126
11111110254-2-126-1
11111111255-1-127-0