That sequencing of casting makes sense - I appreciate the clear explanation.
On Fri, Sep 9, 2011 at 11:12 AM, Tom Lane <tgl@xxxxxxxxxxxxx> wrote:
Henry Drexler <alonup8tb@xxxxxxxxx> writes:
> [ "1/3" yields zero ]
Yeah, it's an integer division.
> float8(1/3)
> I thought perhaps I could cast it as double precision as noted on
> http://www.postgresql.org/docs/8.3/interactive/sql-expressions.html
> though doing the following:
That's casting the result of the division to float, which is way too
late. You need to cast one or both inputs to non-integer, for instance
1.0/3
1/(3::float8)
etc etc.
regards, tom lane