public inbox for [email protected]
help / color / mirror / Atom feedFrom: Adrian Klaver <[email protected]>
To: John Abraham <[email protected]>
To: [email protected]
Subject: Re: Rounding numbers from copy expert
Date: Wed, 24 Jul 2019 16:33:16 -0700
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
On 7/24/19 4:28 PM, John Abraham wrote:
> Hmm, I have two machines connecting to the same database running the
> same query inside copy_expert.
>
> Both seem to have psycopg2 2.7.5 (based on pip3 freeze).
>
> One seems to be rounding the double precision number 696538951.985381 to
> 6.96538944E8 whereas the other machine isn't rounding it.
First:
https://www.postgresql.org/docs/11/datatype-numeric.html#DATATYPE-FLOAT
8.1.3. Floating-Point Types
"The data types real and double precision are inexact,
variable-precision numeric types. ...
Inexact means that some values cannot be converted exactly to the
internal format and are stored as approximations, so that storing and
retrieving a value might show slight discrepancies. Managing these
errors and how they propagate through calculations is the subject of an
entire branch of mathematics and computer science and will not be
discussed here, except for the following points: ..."
Second:
Where are you actually 'looking' at the values?
>
> This is causing auditability/repeatability problems, as the difference
> is actually significant in this context.
>
> Is there some thing about the way psycopg2 connects to the database, or
> the way psycopg2 is configured, that could be causing this rounding? Is
> there some way to express a preference for scientific notation?
>
> I'm at a complete loss as to why copy_expert (which basically does a
> 'copy to stdin' query) would be different when called from different
> machines. My next step in the madness is to see if the locale has an
> effect, one is set to en_CA.UTF-8 and the other is set to en_US.UTF-8.
> But, perhaps someone else has a better idea.
>
> Thanks for any help.
>
> --
> John Abraham
> [email protected] <mailto:[email protected]>
> 403-232-1060
>
--
Adrian Klaver
[email protected]
view thread (4+ messages) latest in thread
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 using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: Rounding numbers from copy expert
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox