Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

Re: evaluating equation stored in a string


  • From: Alban Hertroys <alban(at)magproductions(dot)nl>
  • To: SunWuKung <Balazs(dot)Klein(at)t-online(dot)hu>
  • Cc: pgsql-general(at)postgresql(dot)org
  • Subject: Re: evaluating equation stored in a string
  • Date: Wed, 26 Apr 2006 18:05:45 +0200
  • Message-id: <444F9A59(dot)6000108(at)magproductions(dot)nl>

SunWuKung wrote:
However I have a problem with this cast. I don't know how to handle
brackets in the equation, since

SELECT 35/124 ::numeric
--0.28....

while

SELECT (35/124) ::numeric
-- 0

The brackets aren't your problem, your numbers aren't as accurate as the result you require. An eval() function would give the same results. You'll want this instead:

SQL> select (35.0/124.0)::numeric;
        numeric
------------------------
 0.28225806451612903226


Regards,
--
Alban Hertroys
alban(at)magproductions(dot)nl

magproductions b.v.

T: ++31(0)534346874
F: ++31(0)534346876
M:
I: www.magproductions.nl
A: Postbus 416
   7500 AK Enschede

// Integrate Your World //



Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group