Browse Prior Art Database

# A Method for Implementing Integer Round in the Floating Point Unit

IP.com Disclosure Number: IPCOM000110489D
Original Publication Date: 1992-Nov-01
Included in the Prior Art Database: 2005-Mar-25
Document File: 1 page(s) / 42K

IBM

## Related People

Alpern, B: AUTHOR [+3]

## Abstract

Disclosed is a technique for implementing integer round in the floating point unit of a computer which is running in IEEE Round-to-Nearest mode.

This text was extracted from an ASCII text file.
This is the abbreviated version, containing approximately 86% of the total text.

A Method for Implementing Integer Round in the Floating Point Unit

Disclosed is a technique for implementing integer round in the
floating point unit of a computer which is running in IEEE
Round-to-Nearest mode.

The IEEE floating point standard specifies different rounding
modes.  These differ on how a number b between two consecutive
representable numbers a and c is handled.  In Round-to-Nearest (R2N)
mode, b become whichever of a or c that it is closer to.  If b
is exactly midway between a and c, b becomes whichever of a or c that
has a 0 as its last bit.

Consider  a programming construct ROUND(x) that returns the
nearest (floating-point) whole number to x for x in a given range
(say, between -232 and 232).  If x is exactly midway between two
consecutive whole numbers, ROUND(x) returns the larger of these.

Define MAGIC as 2.052 + 2.051 + 1.  In R2N mode, ROUND can
almost be implemented as follows.  First, add MAGIC to x, then,
subtract MAGIC.  This works all floating point numbers in the range
-251 - 1 and 251 - 1, except those of the form 2.0 x N
- 0.5 where N is a whole number.  Such numbers get rounded to 2.0 x
N - 1.0 rather than to N.

This invention is a program for implementing ROUND in R2N mode.
Similar techniques can be used to implement other rounding and
truncation functions.  The program works for all x in the range -251
to 251 - 1.  A possible drawback of this invention is that it
requires a floa...