From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Ron Johnson <ron(dot)l(dot)johnson(at)cox(dot)net> |
Cc: | pgsql-bugs(at)postgreSQL(dot)org |
Subject: | Re: [NOVICE] Postgres storing time in strange manner |
Date: | 2002-09-17 19:14:54 |
Message-ID: | 1931.1032290094@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs pgsql-novice |
Ron Johnson <ron(dot)l(dot)johnson(at)cox(dot)net> writes:
> Out of curiosity: why does -ffast-math break the datetime rounding code?
We dug into this last night, and it turns out that the culprit is code
like
int hour = time / 3600;
where time is a double. This yields an exact result when done
correctly, but with -ffast-math gcc will "improve" it to
int hour = time * 0.000277777777777778;
the constant being the nearest double value to 1.0 / 3600.0. The
problem is that the constant is inexact and in fact is slightly too
large; so for example if time is exactly 18000.0, you get a resulting
hour value of 4, not 5, after truncation to integer. Repeated a couple
more times, what should have been 5:00:00 comes out as 4:59:60 ...
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2002-09-17 22:13:31 | Re: [NOVICE] Postgres storing time in strange manner |
Previous Message | Tom Lane | 2002-09-17 19:00:42 | Re: Bug #771: rewrite rules on update or insert do not report errors |
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2002-09-17 22:13:31 | Re: [NOVICE] Postgres storing time in strange manner |
Previous Message | Joel Rodrigues | 2002-09-17 19:00:41 | Re: 7.2.2 java configure problem on Mac OS X 10.1.5 |