Appendix B. Fixed-Point and Two's Complement Notation

Afixed-point number is a signed value, recorded as a

binary integer. It is calledfixed point because the pro

grammer determines thefixed positioning of the binary

point.

Fixed-point operands may be recorded in halfword

(16 bits) or word (32 bits) lengths. In both lengths,

thefirst bit position (0) holds the sign of the number,

with the remaining bit positions (1-15 for halfwords

and 1-31 for fullwords) used to designate the mag

nitude of the number.Positive fixed-point numbers are represented in true

binary form with a zero sign bit. Negative fixed-paint

numbers are represented in two's complement notation

with a one bit in the sign position. In all cases, the

bits between the sign bit and the leftmost significant

bit of the integer are the same as the sign bit (i.e.

all zeros for positive numbers, a1l ones for negative

numbers).

Negative fixed-point numbers arc formed in two's

complement notation by inverting each bit of the posi

tive binary number and adding one. For example, the

true binary form of the decimal value (plus 26) is

made negative (minus 26) in the following manner:

+26

Invert

Add 1

-26S INTEGER

o0000000 00011010 1 1111111 11100101 1

1111111111100110 (Two's complement form)

This is equivalent to subtracting the number:0000000000011010 from 1 0000000000000000. 132

The following addition examples illustrate two's

complement arithmetic.Only eight bit positions are

used. All negative numbers are in two's complement

form.COMMENTS +57 00111001 +35 00100011 +92 01011100 +57 00111001 -35 11011101 No overflow

+2200010110 Ignore carry -carry into high

order position and carry out.

+3500100011 -57 11000111 -22 11101010 Sign change only; no carry.

-5711000111 -35 11011101 No overflow

-9210100100 Ignore carry -carry into high

order position and carry out.

-5711000111 -92 10100100 -149 (/01101011 (/Overfiow - no carry into high

order position but carry out.

+5700111001 +92 01011100 149 (/10010101 (/Overflow - carry into high order

position, no carry out.

The following are 16-bit fixed-point numbers. Thefirst is the largest positive number and the last, the

largest negative number.

NUMBER DECIMALS INTEGER 2

'0 -1 32,767 =0 1111111 11111111 2° 1 = 0 0000000 00000001 0 0 = 0 0000000 00000000 _2° -1 =1111111111111111 __ 2]" -32,768 = 1 0000000 00000000 The following are 32 bit fixed-point numbers. The first is the largest positive number that can be repre

sented by 32 bits, and the last is the largest negative

number.

NUMBER

2

31-1 2·'fl 2° o --2" -2' _218 __ 281 +1 =

_2

31

DECIMAL

2147483647

65536

1

o-1 -2 -65536 -2 147483647 -2 147483 648

INTEGER=0 111111111111111 11111111 11111111

=0 0000000 00000001 00000000 00000000 = 0 0000000 00000000 00000000 00000001 = 0 0000000 00000000 00000000 00000000 = 1 111111111111111 11111111 11111111

=1 111111111111111 1111111111111110

= 1 1111111 1111111100000000 00000000 = 1 0000000 00000000 00000000 00000001 = 1 0000000 00000000 00000000 00000000

A

binary integer. It is called

grammer determines the

point.

Fixed-point operands may be recorded in halfword

(16 bits) or word (32 bits) lengths. In both lengths,

the

with the remaining bit positions (1-15 for halfwords

and 1-31 for fullwords) used to designate the mag

nitude of the number.

binary form with a zero sign bit. Negative fixed-paint

numbers are represented in two's complement notation

with a one bit in the sign position. In all cases, the

bits between the sign bit and the leftmost significant

bit of the integer are the same as the sign bit (i.e.

all zeros for positive numbers, a1l ones for negative

numbers).

Negative fixed-point numbers arc formed in two's

complement notation by inverting each bit of the posi

tive binary number and adding one. For example, the

true binary form of the decimal value (plus 26) is

made negative (minus 26) in the following manner:

+26

Invert

Add 1

-26

o

1111111111100110 (Two's complement form)

This is equivalent to subtracting the number:

The following addition examples illustrate two's

complement arithmetic.

used. All negative numbers are in two's complement

form.

+22

order position and carry out.

+35

-57

-92

order position and carry out.

-57

order position but carry out.

+57

position, no carry out.

The following are 16-bit fixed-point numbers. The

largest negative number.

NUMBER DECIMAL

'0

sented by 32 bits, and the last is the largest negative

number.

NUMBER

2

31

_2

31

DECIMAL

2147483647

65536

1

o

INTEGER

=

=1 111111111111111 1111111111111110

= 1 1111111 11111111