From: | Mikael <mikael(dot)aronsson(at)gmail(dot)com> |
---|---|
To: | pgsql-jdbc(at)lists(dot)postgresql(dot)org |
Subject: | Re: PostgresSQL 10 | Driver 42.2.5 | Float Conversion Issue |
Date: | 2020-10-20 19:04:49 |
Message-ID: | 8dc8b2f8-5a08-32e4-9bf7-30673ffe4637@gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
Well, the documentation say:
"The data typesrealanddouble precisionare inexact, variable-precision
numeric types. In practice, these types are usually implementations
ofIEEEStandard 754 for Binary Floating-Point Arithmetic (single and
double precision, respectively), to the extent that the underlying
processor, operating system, and compiler support it.
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"
I think that counts as a big fat warning, it's the same in all SQL
servers, nothing unique for PG, the alternative is of course the NUMERIC
data type.
On 2020-10-20 20:51, Andreas Joseph Krogh wrote:
> På tirsdag 20. oktober 2020 kl. 19:17:54, skrev Tom Lane
> <tgl(at)sss(dot)pgh(dot)pa(dot)us <mailto:tgl(at)sss(dot)pgh(dot)pa(dot)us>>:
>
> Andreas Joseph Krogh <andreas(at)visena(dot)com> writes:
> > How can this be sane?
>
> If you're expecting exact results from float calculations, you need
> a refresher course in what floating-point arithmetic is all about.
>
> From a programming perspective - yes, from a DB-client perspective,
> and in general, no way. In general - "Users" expect "reals" to be just
> "decimal-numbers", so with this behaviour of float in PG so close to
> "C-float" there should, IMO, be a big fat warning "Don't use the float
> datatype, at all" somewhere. Try to tell an accountant that doing
> calculations with floating-point numbers is crazy, and you should
> expect the computer to give you wrong answers...
> --
> *Andreas Joseph Krogh*
> CTO / Partner - Visena AS
> Mobile: +47 909 56 963
> andreas(at)visena(dot)com <mailto:andreas(at)visena(dot)com>
> www.visena.com <https://www.visena.com>
> <https://www.visena.com>
From | Date | Subject | |
---|---|---|---|
Next Message | Andreas Joseph Krogh | 2020-10-20 19:24:02 | Re: PostgresSQL 10 | Driver 42.2.5 | Float Conversion Issue |
Previous Message | David G. Johnston | 2020-10-20 18:59:45 | Re: PostgresSQL 10 | Driver 42.2.5 | Float Conversion Issue |