complement form for signed binary
integers, and the signed-absolute-value
form for the fractions of floating-point
numbers.
The method used here inverts the left
most bit of the 32-bit signed binary
integer, which is equivalent to adding
31
result to be positive.
number from a signed integer
range 2
31
- 1 through -2
31
to an
unsigned integer in the range
32
through o. After conversion to the long
floating-point format, the value 2
31
is
subtracted again.
Assume that general register 9 (GR9)
contains the integer -59 in two's
complement form:
GR9: FF FF FF
storage: TEMP, for use as temporary
storage, and
floating-point constant 2
31
in the
following format:
point number with the characteristic 4E,
which corresponds to a radix point (hex
adecimal point) to the right of the
number.
The following instruction sequence
performs the conversion:
Result
X
7FFF FFC5
ST 9,TEMP+4 TEMP:
xxxx xxxx 7FFF FFC5
the leftmost bit in general register 9,
using the right half of the constant as
the source for a leftmost one bit. The
next two instructions assemble the modi
fied number in an unnormalized long
floating-point format, using the left
half of the constant as the plus sign,
the characteristic, and the leading
zeros of the fraction.
the number unchanged in floating-point
register 2. The
steps by subtracting
31
point form and normalizing the result.
Floating Point to Fixed Point
The procedure described here consists
basically in reversing the steps of the
previous procedure. Two additional
considerations must be taken into
account. First: the floating-point
number may not be an exact integer.
Truncating the excess hexadecimal digits
on the right requires shifting the
number one digit position farther to the
right than desired for the final result,
so that the units digit occupies the
position of the guard digit. Second:
the floating-point number may have to be
tested as to whether it is outside the
range of numbers representable as a
32-bit signed binary integer.
Assume that floating-point register 6
contains the number
in normalized form:
FPR6: 42 3B
in storage: TEMP, for use as temporary
storage, and the constants
32
31
formats:
more position than the constant
the previous example, so as to force the
units digit into the guard-digit posi
tion.
The following instruction sequence
performs the integer truncation, range
tests, and conversion to a signed binary
integer in general register 8 (GR8):
Result
routine if result
is greater than or
equal to zero
AW 6,TW032 FPR6:
routine if result
is less than zero