SAS for
z/OS
uses the traditional IBM mainframe floating-point representation as
follows:
SEEEEEEE MMMMMMMM MMMMMMMM MMMMMMMM
byte 1 byte 2 byte 3 byte 4
MMMMMMMM MMMMMMMM MMMMMMMM MMMMMMMM
byte 5 byte 6 byte 7 byte 8
This representation
corresponds to bytes of data with each character being 1 bit, as follows:
-
The S in byte 1 is the sign bit of the number. A value
of 0 in the sign bit is used to represent positive numbers.
-
The
seven E characters in byte 1 represent a binary integer known as the
characteristic. The characteristic represents a signed exponent and
is obtained by adding the bias to the actual exponent. The bias is
an offset used to enable both negative and positive exponents with
the bias representing 0. If a bias is not used, an additional sign
bit for the exponent must be allocated. For example, if a system uses
a bias of 64, a characteristic with the value 66 represents an exponent
of +2, while a characteristic of 61 represents an exponent of –3.
-
The remaining M characters in bytes 2 through 8 represent
the bits of the mantissa. There is an implied radix point before the
left-most bit of the mantissa. Therefore, the mantissa is always less
than 1. The term radix point is used instead of decimal point because
decimal point implies that you are working with decimal (base 10)
numbers, which might not be the case. The radix point can be thought
of as the generic form of decimal point.
The exponent has a base associated with it. Do not
confuse this with the base in which the exponent is represented; the
exponent is always represented in binary, but the exponent is used
to determine how many times the base should be multiplied by the mantissa.
In the case of the IBM mainframes, the exponent's base is 16. For
other computers, it is commonly either 2 or 16.
Each bit in the mantissa
represents a fraction whose numerator is 1 and whose denominator is
a power of 2. For example, the leftmost bit in byte 2 represents
, the next bit represents
, and so on. In other words, the mantissa is the
sum of a series of fractions such as
,
,
, and so on. Therefore, for any floating-point number
to be represented exactly, you must be able to express it as the previously
mentioned sum. For example, 100 is represented as the following expression:
To illustrate how the
above expression is obtained, two examples follow. The first example
is in base 10. The value 100 is represented as follows:
100.
The period in this number
is the radix point. The mantissa must be less than 1. Therefore,
you normalize this value by shifting the radix point three places
to the left, which produces the following value:
Because the radix point
is shifted three places to the left, 3 is the exponent:
The second example is
in base 16. In hexadecimal notation, 100 (base 10) is written as
follows:
Shifting the radix point
two places to the left produces the following value:
Shifting the radix point
also produces an exponent of 2, as in:
The binary value of
this number is
.01100100
, which can be represented
in the following expression:
In this example, the
exponent is 2. To represent the exponent, you add the bias of 64 to
the exponent. The hexadecimal representation of the resulting value,
66, is 42. The binary representation is as follows:
01000010 01100100 00000000 00000000
00000000 00000000 00000000 00000000