octave-maintainers
[Top][All Lists]

## Re: Directed rounding

 From: Eric Walter Subject: Re: Directed rounding Date: Thu, 17 Sep 2015 18:21:55 +0200 User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.7.0

As I told you in my previous email, my goal was just to point out what would, in my opinion, be a desirable Octave feature. I do not plan to implement it myself.
```
```
Many thanks for the time you took to answer me and for your suggestions. Many somebody else will feel like doing the job.
```
Best,

Eric

Le 17/09/2015 18:09, John W. Eaton a écrit :
```
```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

http://www.springer.com/fr/book/9783319076706#reviews
```
```
```
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
Concepts::.

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
numbers.

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.
```
Thanks,

jwe

```
```

```

reply via email to