Subject: Re: rounding direction

From: "Fred J. Tydeman" <[email-masked]>
Date: Thu, 27 Feb 97 16:17:44 +0100

On Thu, 27 Feb 1997 12:45:32 -0000, Timothy Ritchey wrote:

>I may expose my ignorance about directed rounding, but isn't that what the
>Math class provides in Java?:

Nope.  Directed rounding is concerned with the transformation of the 
infinitly precise mathematical result of each arithmetic operation to
the machine representation nearest to that result in the directed
direction.  So for example, 1.0 + 1.0e-200 is 1.0 in round to nearest,
round toward minus infinity, and round toward zero, but it is 1.0+2.2e-16
(next double bigger than 1.0) in round toward plus infinity.  1.0 + 2.0e-16
is 1.0+2.2e-16 in round to nearest and round to plus infinity, but it is
1.0 in round toward zero and round to minus infinity.

C9X, the revision of C currently under way, added fesetround( int round )
with the argument being one of FE_TONEAREST, FE_UPWARD, FE_DOWNWARD, and
FE_TOWARDZERO, as a means for the programmer to control the floating-point
environment.  It would be nice if this were added to Java.

>double ceil(double a)
>Returns the smallest (closest to negative infinity) double value that is
>not less than the argument and is equal to a mathematical integer.
>
>double floor(double a)
>Returns the largest (closest to positive infinity) double value that is not
>greater than the argument and is equal to a mathematical integer.

---
Fred J. Tydeman    +49 (7031) 288-964  Tydeman Consulting
Meisenweg 20       [email-masked]   Programming, testing, C/C++ training
D-71032 Boeblingen                     Voting member of X3J11 (ANSI "C")
Germany            Sample FPCE tests:  ftp://ftp.netcom.com/pub/ty/tydeman