On 2008-11-06 07:56, Traci Sumpter wrote:

> Equation   (315-0)/180*pi
> PostgreSQL 3.14159265358979

You equation in SQL looks like this:

=> select (315-0)/180*pi from (select 3.14159265358979 as pi) as a;

Which is an equivalent of:

=> select (315/180)*pi from (select 3.14159265358979 as pi) as a;

And because 315 and 180 are integers so (315/180) is rounded down to
integer (1):

=> select 1*pi from (select 3.14159265358979 as pi) as a;

I think you need:

=> select (315.0-0)/180*pi from (select 3.14159265358979 as pi) as a;
5.497787143782132500000000000000

Any strongly typed language will do this, for example in python:

$ python -c 'pi=3.14159265358979; print (315-0)/180*pi;'
3.14159265359
$ python -c 'pi=3.14159265358979; print (315.0-0)/180*pi;'
5.49778714378

Regards
Tometzky
-- 
...although Eating Honey was a very good thing to do, there was a
moment just before you began to eat it which was better than when you
were...
                                                      Winnie the Pooh

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

Reply via email to