Abbreviations and Notations
LSB: Least Significant Bit (right-most bit) |
MSB: Most Significant Bit (left-most bit) |
SaM: Sign-and-Magnitude representation |
OsC: One's Complement representation |
TsC: Two's Complement representation |
|
B_x
: set of bits representing number x
base 10
, i.e. B_x={b_i}, i=[0,N-1]
. : in a 4-bit register, B_x=0101
for x=5
|
Unless specified otherwise, we will use throughout 8-bit (1 byte) registers to represent integers => ranges are [0,255]
for unsigned int
s and [-127, 127]
for signed int
s. |
Types of Number representation
Mainly: SaM, OsC, TsC, excess- K
, Base- 2
|
TsC most widely used. Here, only SaM, OsC and TsC are coverved. |
For SaM/OsC/TsC, B_x
for x>0
is the same for all representations (this is not the case for excess- K
and Base- 2
) =>
half the full range is always B_[0, 127]=[00000000, 01111111]
. |
-x
will then depend on choice of representation. |
|
|
SaM
MSB directly represents the sign. 0
is for positive integers, 1
is for negative integers. Remaining bits are for magnitude |
: x = 43
has B_x = 00101011
=> x = -43
has B_x = 10101011
|
2 representations for 0
( 00000000
( 0
) and 10000000
( −0
)) |
OsC
For x>0
, -x represented by B_(-x) = ~B_x
|
x = 43
has B_x = 00101011
=> x = -43
has B_x = 11010100
|
2 representations for 0
( B_0 = 00000000
and B_(-0) = ~B_0 = 11111111
). In fact B_x + B_(-x) = B_(-0)
|
Sometimes imposes and end-around carry/borrow in addition/subtraction (in a 4
-bit register, try 7-3
, 7+(-3)
, (-7)+3
, 3-7
, with corresponding OsC bit representation). These do not occur in TsC arithmetic |
For x>0
with representation B_x
, B_(-x) = B_x
as per OsC definition <=> B_(-x) = B_0 - B_x
|
|
|
|