[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Directed rounding

From: John W. Eaton
Subject: Re: Directed rounding
Date: Thu, 17 Sep 2015 12:09:30 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.7.0

On 09/17/2015 11:56 AM, Eric Walter wrote:
Dear Juan Pablo,

Thanks for your quick reaction. What I need is a simple way of computing
the smallest /floatting point number/ that is larger than some given
real number that may be the result of some computation, as well as the
largest floatting point number that is smaller that the same real
number. This corresponds to two of the four rounding modes demanded by
IEEE 747. As far as I know, none of the functions that you mention
perform that. MATLAB does not do it, Scilab does not do it either. To
see how these rounding modes may be used to assess number of significant
digits, you may consult chapter 14 of the book


So you are not looking for a function to change the rounding mode, but you want the nextafter function from glibc?

 -- Function: double nextafter (double X, double Y)
 -- Function: float nextafterf (float X, float Y)
 -- Function: long double nextafterl (long double X, long double Y)
     Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety

     The 'nextafter' function returns the next representable neighbor of
     X in the direction towards Y.  The size of the step between X and
     the result depends on the type of the result.  If X = Y the
     function simply returns Y.  If either value is 'NaN', 'NaN' is
     returned.  Otherwise a value corresponding to the value of the
     least significant bit in the mantissa is added or subtracted,
     depending on the direction.  'nextafter' will signal overflow or
     underflow if the result goes outside of the range of normalized

     This function is defined in IEC 559 (and the appendix with
     recommended functions in IEEE 754/IEEE 854).

Or something else? I recommend that you implement this yourself and contribute it.

It looks to me like a simple two-argument mapper function that could be handled internally in Octave the same way as atan2, for example.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]