Search Postgresql Archives

Re: integer instead of 'double precision'?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Henry Drexler <alonup8tb@xxxxxxxxx> writes:
> [ "1/3" yields zero ]

Yeah, it's an integer division.

> 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:
> float8(1/3)

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

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux