Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Interfaces Jdbc > Re: PostgreSQL ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 2 Topic 1922 of 2028
Post > Topic >>

Re: PostgreSQL FUNCTION return problem

by craig@[EMAIL PROTECTED] (Craig Ringer) Apr 7, 2008 at 10:50 PM

Rafael Barrera Oro wrote:
> Hello, i have the following problem and i was wondering if you coulde
help
> me. I'll try to describe it as in depth as i can.
>
>    I have a FUNCTION in a postgresql database which subtracts two DOUBLE
> PRECISION FIELDS and returns the result. The problem is that when the
result
> should be zero, the number i
> get is a number ridiculously close to zero in scientific notation (for
> example 2.4697823124E-14) but not zero.

Start here:

http://www.google.com/search?q=floating+point+rounding

The short answer is - never expect the subtraction of two "equal" 
floating point values to be zero. Instead of testing with equality, test 
with a very small range.

If you really need exact values (say, you're working with money) use the 
NUMERIC type instead.

--
Craig Ringer

-- 
Sent via pgsql-jdbc mailing list (pgsql-jdbc@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc
 




 2 Posts in Topic:
PostgreSQL FUNCTION return problem
borafael@[EMAIL PROTECTED  2008-04-07 11:35:22 
Re: PostgreSQL FUNCTION return problem
craig@[EMAIL PROTECTED]   2008-04-07 22:50:54 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun Sep 7 1:48:35 CDT 2008.