3.0.1 release?
John W. Eaton
jwe at bevo.che.wisc.edu
Wed Apr 9 12:35:22 CDT 2008
On 9-Apr-2008, Michael Goffioul wrote:
| On Wed, Apr 9, 2008 at 1:51 AM, John W. Eaton <jwe at bevo.che.wisc.edu> wrote:
| > I suppose we could write something like
| >
| > double ip;
| > return modf (x, &ip) == 0.0 ? x : (x > 0 ? floor (x + 0.5) : ceil (x - 0.5));
| >
| > Is there a better (and still portable) way to determine whether a
| > double value is an integer?
|
| The following code seems to work fine:
|
| if (x >= 0)
| {
| double y = floor (x);
|
| if ((x - y) >= 0.5)
| y += 1.0;
|
| return y;
| }
| else
| {
| double y = ceil (x);
|
| if ((y - x) >= 0.5)
| y -= 1.0;
|
| return y;
| }
I applied the patch you sent in a mail off the list.
| This is taken from gnulib:round.c (I guess it's no problem to grab
| some code from GPL project to put it into another GPL
| project). Running the test suite does not seem to return new
| problems.
It is OK. If it is significant, we should note the origin.
We should pobably be using more code from gnulib, but not just by cut
and paste. Doing that requires some extra Makefile effort.
jwe
More information about the Octave-maintainers
mailing list