representing (seconds + microseconds) as floats [was:Re: Interval support for Postgres]

From: Vadim Nasardinov <vadimn(at)redhat(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: representing (seconds + microseconds) as floats [was:Re: Interval support for Postgres]
Date: 2005-04-22 13:56:17
Message-ID: 200504220956.17630@vadim.nasardinov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On Thursday 21 April 2005 17:47, Oliver Jowett wrote:
> Kris Jurka wrote:
> > 1) You have an "int milliseconds" field. PG supports microsecond
> > precision in intervals. Is there any reason not to go with a
> > plain "float seconds" field instead of splitting these up?
>
> Can you represent all of 0.000000 .. 59.999999 exactly as floats?

Seem like you more or less can -- up to 16.000001:

| $ cat QuickTest.java
| public class QuickTest {
| public static void main(String[] _) {
| System.out.println("16.000001f - 16.000000f = " +
| (16.000001f - 16.000000f));
|
| System.out.println("16.000002f - 16.000001f = " +
| (16.000002f - 16.000001f));
| }
| }
|
| $ javac QuickTest.java
|
| $ java -cp . QuickTest
| 16.000001f - 16.000000f = 1.9073486E-6
| 16.000002f - 16.000001f = 0.0

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Dave Cramer 2005-04-22 14:16:08 Re: BUG? res.next() == false, but psql finds tuples?
Previous Message Palle Girgensohn 2005-04-22 13:43:43 BUG? res.next() == false, but psql finds tuples?