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
5. The characteristic is developed from the exponent and
converted to binary.
base + = characteristic
64 + 2 =66 = 1000010 6. The fraction is converted to binary and grouped hexa­ decimally. 0.954 16 == .1001 0101 0100 7. The characteristic and the fraction are stored in the
short format. The sign position contains the sign of the
fraction. SChar Fraction
o 1000010 1001 0101 0100 0000 0000 0000 The following are sample normalized short floating-point
numbers. The last two numbers represent the smallest and
the largest positive normalized numbers.
Number Powers of 76 .E Fraction 1.0 = +1/16 x 16
1
= 0 100 0001 0001 0000 0000 0000 0000 0000 0.5 = +8/16 x 16° = 0 100 0000 1000 0000 0000 0000 0000 0000 1/64 = +4/16 x 16-
1
= 0 011 1111 0100 0000 0000 0000 0000 0000 0.0 = +0 x 16-
64 = 0 000 0000 0000 0000 0000 0000 0000 0000 -15.0 =-15/16x16
1
= 110000011111000000000000 0000 0000 5.4 x 10-
79
= 0 000 0000 000100000000 0000 0000 0000 7.2xl0
75
';t (1-16-
6
)x16
63 0 1111111111111111111111111111111
Instruction-Use Examples
The following examples illustrate the use of many System/370
instructions. Before studying one of these examples, the
reader should first consult the instruction description in this
manual for the particular instruction of interest to him. Please note that this publication, and the instruction-use
examples, are written principally for assembly-language pro­ grammers, to be used in conjunction with the appropriate
assembly-language manuals.
For clarity, and for ease in programming, each example in
this section presents the instruction both as it is written in
an assembly-language statement and as it appears when
assembled in storage (machine format).
Machine Format
As a rule, all machine format numerical operands are written
in hexadecimal notation unless otherwise specified. Hexa­ decimal operands are shown converted into binary, decimal,
or both, if such conversion helps to clarify the example for
the reader. Storage addresses are also given in hexadecimal.
Assembly-Language Format
In assembly-language statements, registers, lengths, and
masks are all presented in decimal, but displacements may
be in hexadecimal or decimal. (A hexadecimal displacement
is indicated by X'n', where n can range from OOO-FFF.) Im­ mediate operands are normally shown in hexadecimal. When-
ever the value in a register or storage location is referred to
as "not significant," this value is replaced during the execu­ tion of the instruction.
When SS-format instructions are written in System/370
assembly language, lengths are given as the total number of
bytes in the field. This differs from the machine definition,
in which the length field specifies the number of bytes to
be added to the field address to obtain the address of the
last byte of the field. Thus, the machine length is one less
than the assembly-language length. The assembly program
automatically subtracts one from the length specified when
the instruction is assembled.
In some of the examples, symbolic addresses are used in
order to simplify the examples. In assembly-language state­ ments, a symbolic address is represented as a mnemonic
term written in all capitals, such as FLAGS, which is used
to denote the address of a storage location used to contain
data or program-control information. When symbolic ad­ dresses are used, the assembler supplies actual base and dis­ placement values according to the USING and DROP assembler instructions.
When symbolic addresses are used in the example, the
values for base and displacement are not shown in the
assembly-language format or in the machine-language format.
For assembly-language formats, the letter S in the labels
that designate instruction fields is used to indicate the com­ bination of base and displacement fields for an operand
address. (For example, S 1 represents the combination of
Bl and Dl.) In the machine-language format, the base and
displacement address components are shown as asterisks (*).
Add Halfword (AH)
The ADD HALFWORD instruction algebraically adds the
halfword contents of a storage location to the contents of a
register. The halfword storage operand is expanded to 32
bits after it is fetched and before it is used in the add oper­ ation. The expansion consists in propagating the leftmost
(sign) bit 16 positions to the left. For example, assume that
the contents of storage locations 2000-2001 are to be added
to register 5. Initially:
Register 5 contains 00 00 00 19 = 2510 Storage locations 2000-2001 contain FF FE == -2 1 0 Register 12 contains 00 00 18 00. Register 13 contains 00 00 01 50. The format of the required instruction is:
Machine Format Op Code R1 X
2
8
2 02 4A I 5 I ° I C 6
8
9
Assembler Format Op Code R
1
, 02 (X2, 82)
AH 5, X'680'(13,12)
Appendix I. Number Representation and Instruction-Use Examples 291
Previous Page Next Page