Re: BUG #4514: Pi division error
От | Tomasz Ostrowski |
---|---|
Тема | Re: BUG #4514: Pi division error |
Дата | |
Msg-id | 4912FFD8.7030208@batory.org.pl обсуждение исходный текст |
Ответ на | BUG #4514: Pi division error ("Traci Sumpter" <traci.sumpter@opus.com.au>) |
Список | pgsql-bugs |
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
В списке pgsql-bugs по дате отправления: