octave-maintainers
[Top][All Lists]
Advanced

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

Re: 3.0.1 release?


From: John W. Eaton
Subject: Re: 3.0.1 release?
Date: Wed, 09 Apr 2008 13:35:22 -0400

On  9-Apr-2008, Michael Goffioul wrote:

| On Wed, Apr 9, 2008 at 1:51 AM, John W. Eaton <address@hidden> 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


reply via email to

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