Skip site navigation (1) Skip section navigation (2)

Re: [NOVICE] Postgres storing time in strange manner

From: Sean Chittenden <sean(at)chittenden(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Ron Johnson <ron(dot)l(dot)johnson(at)cox(dot)net>, pgsql-bugs(at)postgreSQL(dot)org
Subject: Re: [NOVICE] Postgres storing time in strange manner
Date: 2002-09-18 18:31:44
Message-ID: 20020918183144.GP99484@perrin.int.nxad.com (view raw or flat)
Thread:
Lists: pgsql-bugspgsql-novice
> > After looking through gcc, using -O and -ffast-math will create broken
> > code, but -O2 -ffast-math _should_ be okay.
> 
> At least in the gcc shipped with Red Hat 7.2, it doesn't seem to matter:
> you get the wrong answer regardless of -O level.  Here's the test case
> I used:
> 
> [tgl(at)rh1 tgl]$ cat bug.c
> #include <stdio.h>
> 
> double d18000 = 18000.0;
> 
> main() {
>   int d = d18000 / 3600;
>   printf("18000.0 / 3600 = %d\n", d);
>   return 0;
> }
> [tgl(at)rh1 tgl]$ gcc  bug.c
> [tgl(at)rh1 tgl]$ ./a.out
> 18000.0 / 3600 = 5				-- right
> [tgl(at)rh1 tgl]$ gcc -O2 -ffast-math bug.c
> [tgl(at)rh1 tgl]$ ./a.out
> 18000.0 / 3600 = 4				-- wrong
> -- I get 4 if -ffast-math, -O doesn't affect it
> [tgl(at)rh1 tgl]$ gcc -v
> Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs
> gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-98)

Heh, chalk this one up as another Linux-ism then 'cause it's not
present in FreeBSD -stable or -current.  This actually makes me feel
better about setting an option in the -devel port for turning on
compilation with -O3.  -sc

stable$ gcc -v
Using builtin specs.
gcc version 2.95.4 20020320 [FreeBSD]

current$ gcc -v
Using built-in specs.
Configured with: FreeBSD/i386 system compiler
Thread model: posix
gcc version 3.2.1 [FreeBSD] 20020901 (prerelease)

-- 
Sean Chittenden

In response to

pgsql-novice by date

Next:From: Jim BeckstromDate: 2002-09-18 18:47:01
Subject: Serial Field Autoincrementing
Previous:From: Tom LaneDate: 2002-09-18 15:06:10
Subject: Re: [GENERAL] Still big problems with pg_dump!

pgsql-bugs by date

Next:From: pgsql-bugsDate: 2002-09-18 19:18:24
Subject: Bug #772: Rewriting on multi-record updates is unreliable
Previous:From: Sean ChittendenDate: 2002-09-18 18:17:00
Subject: SET autocommit begins transaction?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group