This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [testsuite gfortran] partial fix for secnds*.f
- From: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- To: Rask Ingemann Lambertsen <rask at sygehus dot dk>
- Cc: base at chatta dot us, Thomas Koenig <tkoenig at alice-dsl dot net>, Dominique Dhumieres <dominiq at lps dot ens dot fr>, brooks dot moses at codesourcery dot com, gcc-patches at gcc dot gnu dot org, fortran at gcc dot gnu dot org
- Date: Mon, 28 May 2007 20:32:33 -0700
- Subject: Re: [testsuite gfortran] partial fix for secnds*.f
- References: <1180380870.19525.ezmlm@gcc.gnu.org> <465B0E0B.90309@chalice.us> <20070529024158.GL5690@sygehus.dk>
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