This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [testsuite gfortran] partial fix for secnds*.f


On Tue, May 29, 2007 at 04:41:58AM +0200, Rask Ingemann Lambertsen wrote:
> On Mon, May 28, 2007 at 05:14:51PM +0000, R. D. Flowers, Chattanooga TN USA wrote:
> > >
> > >I think we should use parentheses to enforce the order.
> > 
> > I could be missing something here, and it is almost separate statements, 
> > and might be ugly, but -- comma clauses?
> > 
> > foo=term1,foo+=term2,foo+=term3 ... ;
> 
> <URL:http://gcc.gnu.org/bugs.html#nonbugs_c>
> 

I should probably not post, but has any thought about using simply integers.
In date_and_time.c(secnds), we see

  temp1 = 3600.0 * (GFC_REAL_4)values[4] +
            60.0 * (GFC_REAL_4)values[5] +
                   (GFC_REAL_4)values[6] +
           0.001 * (GFC_REAL_4)values[7];

where values[4] is in [0,23]; values[5] is in [0,59], values[6] is in [0,59], and
values[7] is in [0,999].  For millisecond resolution, we then have

 temp1 = (1000 * (3600 * values[4] + 60 * values[5] + values[6]) + values[7]) / 1000.;

The factor in parenthesis is at most 86399999.  The division is done in double, so
the 8 digits yields at most 10 ms accuracy when cast via GFC_REAL_4.  In fact, we
can get rid of the fmod() by doing something like

 itmp 1000 * (3600 * values[4] + 60 * values[5] + values[6]) + values[7];
 if (itmp > 8639994) itmp = 0;
 temp1 = (GFC_REAL_4) (itmp / 1000.);
 
Now, the broken testcase can also use the same integer arithmetic.

-- 
Steve


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]