representing (seconds + microseconds) as floats [was:Re: Interval support for Postgres] - Mailing list pgsql-jdbc

From Vadim Nasardinov
Subject representing (seconds + microseconds) as floats [was:Re: Interval support for Postgres]
Date
Msg-id 200504220956.17630@vadim.nasardinov
Whole thread Raw
In response to Re: Interval support for Postgres  (Oliver Jowett <oliver@opencloud.com>)
List 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

pgsql-jdbc by date:

Previous
From: Palle Girgensohn
Date:
Subject: BUG? res.next() == false, but psql finds tuples?
Next
From: Dave Cramer
Date:
Subject: Re: BUG? res.next() == false, but psql finds tuples?