Received: from localhost (unknown [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 062B69F984F for ; Wed, 5 Sep 2007 08:42:20 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 29089-10 for ; Wed, 5 Sep 2007 08:42:03 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from rv-out-0910.google.com (rv-out-0910.google.com [209.85.198.190]) by postgresql.org (Postfix) with ESMTP id DCA399F9611 for ; Wed, 5 Sep 2007 08:42:02 -0300 (ADT) Received: by rv-out-0910.google.com with SMTP id l15so1313709rvb for ; Wed, 05 Sep 2007 04:42:01 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=nDkEwS1YC+WdDC14Qba1MSdi5qJqimNqhhlQ9+P8zVE72/YrbZBcXRxuZPMpAnR4rP0OW8/9GtLKJViDi+9NWgK0H6MpYoISUNsgopoM3xqBauvbYa9nTYsR+RPneeuyQTcTQId22/FrEWW1AkPLKsJbOLcn4h5XNm2Oi86Iacs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=aB8JygJCjhxAEfZH4H/SxRQNjEoYwZO0OSpPMVxFacGJVXBypwn8xTWge+LpSGf4UPo4mkL3iNgx/MwYdMmTytQPJVBFRuW/aFaWqn8+wtTviaFOwvMUTp8aZafF7CL+pbuNVGBE5V4mI2ZSFMrB/B1aZ6kzXzECqg63QVcxXtg= Received: by 10.141.71.19 with SMTP id y19mr1442853rvk.1188992520701; Wed, 05 Sep 2007 04:42:00 -0700 (PDT) Received: by 10.141.69.7 with HTTP; Wed, 5 Sep 2007 04:42:00 -0700 (PDT) Message-ID: Date: Wed, 5 Sep 2007 13:42:00 +0200 From: "Peter Kovacs" To: "Heikki Linnakangas" Subject: Re: PreparedStatement rounds doubles to scale 14 during update Cc: pgsql-jdbc@postgresql.org In-Reply-To: <46DE7E7A.70208@enterprisedb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <46DE7E7A.70208@enterprisedb.com> X-Google-Sender-Auth: 8e0fe14220493d94 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200709/15 X-Sequence-Number: 17437 Heikki, Thank you for your reply. What are base-10 datatypes? Are they numeric types? I cannot find them in the backend documentation. Is there a mapping of Java types to backend types documented somewhere? Thanks a lot Peter On 9/5/07, Heikki Linnakangas wrote: > Peter Kovacs wrote: > > Hi, > > > > I have the following problem with postgresql-8.1-407.jdbc3.jar used > > against a 8.1 version backend. > > > > A table "chemterms_cols_test" has a column "logp" defined as: > > > > logp numeric(30,17) > > > > The double value 6.118992224252588 gets rounded to 6.11899222425259000 > > during updates with PreparedStatements using place-holder. (There is > > no rounding with Statement and the value specified in the SQL > > literally.) Is this the expected behaviour? > > The problem is in the conversion from double to numeric in the server. > The server-side float8 data type doesn't have enough precision for that > many decimal places. Because converting between numeric and > floating-point data types almost always leads to rounding errors at some > point, I would strongly recommend sticking to base-10 data types > everywhere if you care about the precision. > > If you use BigDecimal instead of double in your java-program, it works fine. > > -- > Heikki Linnakangas > EnterpriseDB http://www.enterprisedb.com >