| From: | Chris <dmagick(at)gmail(dot)com> | 
|---|---|
| To: | tom <tom(at)tacocat(dot)net> | 
| Cc: | Postgresql <pgsql-general(at)postgresql(dot)org> | 
| Subject: | Re: a math question | 
| Date: | 2007-04-26 03:45:17 | 
| Message-ID: | 4630204D.60803@gmail.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-general | 
tom wrote:
> In pgsql I have to modify this a bit with 'cast (s_msgs as double 
> precision)' or 'cast(s_msgs as real)' in order to get floating point math.
> ( cast(s_msgs as double precision)/S_msgs)  and so on...
> 
> Question:  Is there a better way to get floating point math out of a set 
> of integers?
Nope.
This is mentioned in the docs: 
http://www.postgresql.org/docs/8.2/static/functions-math.html
division (integer division truncates results)
I'm sure it's because of sql specs but someone else will throw their 
2c's in if that's wrong ;)
You only need one real or double precision field in there for that not 
to be truncated, you don't need to cast everything.
-- 
Postgresql & php tutorials
http://www.designmagick.com/
| From | Date | Subject | |
|---|---|---|---|
| Next Message | A. Kretschmer | 2007-04-26 05:17:46 | Re: Business days | 
| Previous Message | Bill Moran | 2007-04-26 02:52:49 | Re: Feature request - have postgresql log warning when new sub-release comes out. |