Skip site navigation (1)
Skip section navigation (2)
## Re: BUG #4514: Pi division error

### In response to

### pgsql-bugs by date

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

- BUG #4514: Pi division error at 2008-11-06 06:56:07 from Traci Sumpter

Next: From:Alex HunsakerDate:2008-11-06 15:37:58Subject: Re: plperl & sortPrevious: From: Tom LaneDate: 2008-11-06 14:13:58Subject: Re: BUG #4515: UPDATE strange behavior