pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Michael Nacos <m.nacos@gmail.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: real -> numeric -> real result different through jdbc
Date: Fri, 11 Dec 2009 11:29:23 -0500
Message-ID: <19400.1260548963@sss.pgh.pa.us> (raw)
In-Reply-To: <407fa4640912110805m67b2bdfr8e4ff703647b6f8b@mail.gmail.com>
References: <407fa4640912110805m67b2bdfr8e4ff703647b6f8b@mail.gmail.com>

Michael Nacos <m.nacos@gmail.com> writes:
> what's the story here? how can the jdbc driver affect the precision of real
> to numeric / numeric to real casts within PL/pgSQL functions?

I seem to recall hearing that JDBC fools with the extra_float_digits
setting.  The "0.60000002" looks like it probably is the actual result
of casting 0.6 to float4 --- remember float4 is only good to about six
decimal digits.  The default display of float4 rounds off at six digits,
but in some contexts you don't want that rounding to happen because it
might result in losing even more precision.  JDBC is being conservative
and taking the latter approach.

			regards, tom lane



view thread (4+ messages)  latest in thread

Message-ID: <19400.1260548963@sss.pgh.pa.us>
Permalink:  ../19400.1260548963@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/19400.1260548963@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: tgl@sss.pgh.pa.us, m.nacos@gmail.com
  Subject: Re: real -> numeric -> real result different through jdbc
  In-Reply-To: <19400.1260548963@sss.pgh.pa.us>
  References: <407fa4640912110805m67b2bdfr8e4ff703647b6f8b@mail.gmail.com> <19400.1260548963@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox