Appendix B. Fixed-Point and Two's Complement Notation
A fixed-point number is a signed value, recorded as a
binary integer. It is called fixed point because the pro­
grammer determines the fixed positioning of the binary
point.
Fixed-point operands may be recorded in halfword
(16 bits) or word (32 bits) lengths. In both lengths,
the first 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
-26 S INTEGER
o 0000000 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
+22 00010110 Ignore carry -carry into high
order position and carry out.
+35 00100011 -57 11000111 -22 11101010 Sign change only; no carry.
-57 11000111 -35 11011101 No overflow
-92 10100100 Ignore carry -carry into high
order position and carry out.
-57 11000111 -92 10100100 -149 (/01101011 (/Overfiow - no carry into high
order position but carry out.
+57 00111001 +92 01011100 149 (/10010101 (/Overflow - carry into high order
position, no carry out.
The following are 16-bit fixed-point numbers. The first is the largest positive number and the last, the
largest negative number.
NUMBER DECIMAL S INTEGER 2
'0
-1 32,767 =0 1111111 11111111 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 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 11111111 00000000 00000000 = 1 0000000 00000000 00000000 00000001 = 1 0000000 00000000 00000000 00000000
Floating-point arithmetic simplifies programming by
automatically maintaining binary point placement
( scaling) during computations in which the range of
values used vary widely or are unpredictable.
The key to floating-point data representation is the
separation of the significant digits of a number from
the size (scale) of the number. Thus, the number is
expressed as a fraction times a power of 16.
A floating-point number has two associated sets of
values. One set represents the significant digits of the
num ber and is called the fraction. The second set
specifies the power (exponent) to which 16 is raised
and indicates the location of the binary point of the
number.
These two numbers (the fraction and exponent) are
recorded in a single word or double-word. Since each of these two numbers is signed, some
method must be employed to express two signs in an
area that provides for a single sign. This is accom­ plished by having the fraction sign use the sign associ­ ated with the word (or double word) and expressing
the exponent in excess 64 arithmetic; that is, the ex­ ponent is added as a signed number to 64. The result­ ing number is called the charactcristic. Since 64 uses 7
bits, the characteristic can vary from 0 to 127, permit­ ting the exponent to vary from -64 through 0 to +63.
This provides a decimal range of n x 10
75
to n x 10-
78
Floating-point data in the System/360 may be re­ corded in short or long formats, depending on the
precision required. Both formats use a sign bit in bit
position 0, followed by a characteristic in bit positions
1-7. Short-precision floating-point data operands con­ tain the fraction in bit positions 8-31; long-precision
operands have the fraction in bit positions 8-63.
Short-Precision Floating-Point Format Is I Characteristic I Fraction
o 1 7 8 31
Long-Precision Floating-Point Format _________ F_ra_c_ti_o_n ______ ____ o 1 7 8 63
The sign of the fraction is indicated by a zero or one
bit in bit position 0 to denote a positive or negative
fraction, respectively.
Appendix C. Floating-Point Arithmetic
Within a given fraction length (24 or 56 bits), a
floating-point operation will provide the greatest pre­ cision if the fraction is normalized. A fraction is nor­ malized when the high-order digit (bit positions 8,
9, 10 and 11) is not zero. It is unnormalized if the
high-order digit contains all zeros.
If normalization of the operand is desired, the float­ ing-point instructions that provide automatic normal­ ization are used. This automatic normalization is ac­ complished by left-shifting the fraction (four bits per
shift) until a nonzero digit occupies the high-order
digit position. The characteristic is reduced by one for
each digit shifted. Conversion Example Convert the decimal number 149.25 to a short-preci­
sion floating-point operand.
1. The number is decomposed into a decimal integer
and a decimal fraction.
149.25 149 plus 0.25 2. The decimal integer is converted to its hexadeci­
mal representation.
14910
3. The decimal fraction is converted to its hexadeci­
mal representation. 0.2510 4. Combine the integral and fractional parts and ex­ press as a fraction times a power of 16 (exponent).
95.4]6 (0.954 X 16
2
ha
5. The characteristic is developed from the expon­ ent and converted to binary.
base + exponent characteristic
64 + 2 = 66 = 1 0 0 0 0 1 0 6. The fraction is converted to binary and grouped
hexadecimally. .95410 = .1001 0101 0100 7. The characteristic and the fraction are stored in
short precision format. The sign position contains the
sign of the fraction.
S Char Fraction
o 1000010 100101010100000000000000 Appendix C 133
Previous Page Next Page