Appendix I. Number Representation and Instruction-Use Examples
Number Representation FIXED-POINT WITH TWO'S COMPLEMENT
A fixed-point number is a signed value, recorded as a binary
integer. It is called fixed-point because the programmer de­ termines the fixed positioning of the radix point.
Fixed-point operands may be recorded in halfword (16-
bit) or word (32-bit) lengths. In both len-gths, 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 magnitude of the number.
Positive fixed-poirit numbers are in true binary
form with a zero sign bit. Negative fixed-point numbers are
represented in two's-complement notation with a one bit in
the sign position. In aU cases, the bits between the sign bit
and the leftmost significant bit of the integer are the same
as the sign bit (that is, 311 zeros for positive numbers, ql1 ones for negative numbers).
Negative fixed-point numbers are formed in two's-comple­ ment notation by inverting each bit of the positive binary
number and adding one. For example, the true binary form
of the decimal value (+26) is made negative (-26) in the
following manner:
+26
Invert
Add 1
-26
S Integer
o 000 0000 0001 1010 1 111 1111 1110 0101 1
111 1111 1110 0110 (Two's-complement
form)
This is equivalent to subtracting the number 0000 0000 0001 1010 from
1 0000 0000 0000 0000 The following addition examples illustrate two's-comple­ ment arithmetic. Only eight bit positions are used. All
negative numbers are in two's-complement form.
1.
2.
3.
+57
+35
+92
+57
-35
+22
+35
-57
-22 0011 1001 0010 0011 0101 1100 0011 1001 1101 1101 No overflow. 0001 0110 Ignore carry-carry into high-order
position and carry out. 0010 001l 1100 0111 1110 1010 Sign change only; no carry
4. -57 1100 0111 -35 1101 1101 No overflow.
-92 1010 0100 Ignore carry-carry into high-order
position and carry out.
5. -57 = 1100 0111 -92 = 1010 0100 -149 = *0110 1011 *Overflow-no carry into high-order
position but carry out.
6. +57 0011 1001 +92 0101 1100 149 = *1001 0101 *Overflow-carry into high-order
position, no carry out.
The presence or absence of an overflow condition may be
recognized by the condition of the carries. There is no overflow:
a. If there is a carry into the high-order bit position and
also a carry out 2 and 4).
b. If there is no carry into the high-order bit position
and no carry out (examples 1 and 3). There is an overflow:
a. If there is no carry into the high-order position but
there is a carry out (example 5).
b. If there is a carry into the high-order position but no
carry out (example 6).
The following are 16-bit fixed-point numbers. The first is
the largest 16-bit positive number and the last, the largest
16-bit negative number.
Number
2
15
- 1 o
- _ 215
Decimal
32,767
1
o
-1
= -32,768
S Integer
o 111 1111 1111 1111
o 000 0000 0000 0001 o 000 0000 0000 0000 1 111 1111 1111 1111
1 000 0000 0000 0000 The following are 32-bit fixed-point numbers. The first is
the largest positive number that can be represented by 32
bits, and the last is the largest negative number that can be
represented by 32 bits.
Number o
Decimal 5 Integer
2147483647 = 0 111 1111 1111 1111 1111 1111 1111 1111
65 536 = 0 000 0000 0000 0001 0000 0000 0000 0000 1 = 0 000 0000 0000 0000 0000 0000 0000 0001 o = 0 000 0000 0000 0000 0000 0000 0000 0000 -1 = 1 111 1111 1111 1111 1111 1111 1111 1111
_21 -2= 11111111111111111111111111111110
_2
16
-65536= 11111111111111110000000000000000 _2
3i
+1 =-2147483647= 1000000000000000 0000 0000 0000 0001 = -2147483648 = 1 000 0000 0000 0000 0000 0000 0000 0000 Appendix I. Number Representation and Instruction-Use Examples 289
FLOATING POINT Floating-point arithmetic simplifies the programming of
computations in which the range of values used varies widely.
It is called floating point because the radix-point placement,
or scaling, is automatically maintained by the machine.
The key to floating-point data representation is the sepa­ ration 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 number 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.
The two numbers (the fraction and exponent) are recorded
in a single word, a doubleword, or two doublewords.
Since each of these two numbers is signed, some method
must be employed to express two signs in an area that pro­ vides for a single sign. This is accomplished by having the
fraction sign use the sign associated with the word (or
doubleword) and expressing the exponent in exccss-64
notation; that is, the exponent is added as a signed number
to 64. The resulting number is called the characteristic. The
characteristic can vary from ° to 127, permitting the expo­ nent to vary from -64 through ° to +63. This provides a
scale multiplier in the range of 16 -64 to 16 + 63. A nonzero
fraction, if normalized, must be less than one and greater
than or equal to 1/16, so the range covered by the magni­ tude (M) of a floating-point number is:
L6 -65 M < 16
63
or more precisely:
In the short format:
16 -6
5 M (1 _ 16 -6) X 16
63
In the long format:
16 -6 5 M (1 _ 16 -14 ) X 16
6
3
In the extended format: 16-
65
:::;;;
M (1 - 16-
28
) X 16
63
In decimal terms:
16-
65
is approximately equal to 5.4 x 10-
79
16
63
is a.pproximately equal to 7.2 x 10
75
Floating .. point data in System/370 may be recorded in
short, long, or extended formats. Each format uses a sign
bit in bit position 0, followed by a characteristic in bit
positions 1-7. Short floating-point operands contain the
fraction in bit positions 8-31; long operands have the frac­ tion in bit positions 8-63; and extended operands have the
fraction in bit positions 8-63 and 72-127. 290 System/370 Principles of Operation Short Floating-Point Number I ___ C_h_ar_a_ct_e_ri_st_ic __ ___ 6_-D __ o 1 8 31
Long Floating-Point Number I s I Characteristic
o 1 8 r_ac_t_i o_n ___ ....J1 63
Extended Floating-Point Number I s I Characteristic
o 1 I High-Order Half of 28-Digit Fraction
8 l 63 Low-Drder Half of Fraction
64 72 127
The sign of the fraction is indicated by a zero or one bit in
bit position ° to denote a positive or negative fraction,
respectively.
Within a given fraction length (6, 14, or 28 digits), a
floating-point operation provides the greatest precision if
the fraction is normalized. A fraction is normalized when
the high-order digit (bit positions 8, 9, 10, and 11) is non­ zero. It is unnormalized if the high-order digit contains all
zeros.
If normalization of the operand is desired, the floating­ point instructions that provide automatic normalization are
used. This automatic normalization is accomplished by
left-shifting the fraction (four bits per shift) until a nonzero
digit occupies the high-order digit position. The character­ istic is reduced by one for each digit shifted. CONVERSION EXAMPLE
Convert the decimal nllmber 149.25 to a short-precision
floating-point operand. (Appendix G provides tables for
the conversion of hexadecimal and decimal integers and
fractions.)
1. The number is decomposed into decimal integer and a
decimal fraction:
149.25 = 149 plus 0.25 2. The decimal integer is converted to its hexadecimal
representation. 149 10 = 9516
3. The decimal fraction is converted to its hexadecimal
representation. 0. 25 10 = 0.4 16 4. Combine the integral and fractional parts and express
as a fraction times a power of 16 (exponent).
95.4 16 =0.95416 X 16
2
Previous Page Next Page