Re: Bug #878: different format of float values in 7.2.and

Lists: pgsql-bugs
From: pgsql-bugs(at)postgresql(dot)org
To: pgsql-bugs(at)postgresql(dot)org
Subject: Bug #878: different format of float values in 7.2.and 7.3
Date: 2003-01-20 08:13:38
Message-ID: 20030120081338.B363F475FD4@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Denis N.Stepanov (D(dot)N(dot)Stepanov(at)inp(dot)nsk(dot)su) reports a bug with a severity of 2
The lower the number the more severe it is.

Short Description
different format of float values in 7.2.and 7.3

Long Description
There is a difference in return value of some floating point operations in PostgreSQL 7.2 and 7.3. The return value in 7.3 contains padding to the right zeroes, while in 7.2 it does not. This is a compartibility problem in fact since our application used to deal with exact float strings without any unnecessary padding zeroes. I use a usual postgresql*-7.3.1-1PGDG.i386.rpm taken from your site, if it makes sense. Please take a look into this.

Sample Code
The following line:

SELECT 1875/1000.0

produces different results. In 7.2.3 it is:

?column?
---------------------
1.875

while in 7.3.1 it is:

?column?
---------------------
1.87500000000000000

No file was uploaded with this report


From: Marcin Winkler <qurczak(at)wolomin(dot)biz>
To: D(dot)N(dot)Stepanov(at)inp(dot)nsk(dot)su, pgsql-bugs(at)postgresql(dot)org
Subject: Re: Bug #878: different format of float values in 7.2.and
Date: 2003-01-20 11:41:48
Message-ID: 20030120124148.0602dcc6.qurczak@wolomin.biz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

On Mon, 20 Jan 2003 03:13:38 -0500 (EST)
pgsql-bugs(at)postgresql(dot)org wrote:

> strings without any unnecessary padding zeroes. I use a usual
> postgresql*-7.3.1-1PGDG.i386.rpm taken from your site, if it makes
> sense. Please take a look into this.
>
> Sample Code
> The following line:
>
> SELECT 1875/1000.0
>
> produces different results. In 7.2.3 it is:
>
> ?column?
> ---------------------
> 1.875
>
> while in 7.3.1 it is:
>
> ?column?
> ---------------------
> 1.87500000000000000

qurczak=# SELECT 1875::float/1000.0;
?column?
----------
1.875
(1 row)

qurczak=# SELECT (1875/1000.0)::float;
float8
--------
1.875
(1 row)

It works ;] You try something this int/float = yee khmm but
int::float/float= float, or something like this ;]

--
"Nieobecni nie majÄ… racji"

Marcin Winkler


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: D(dot)N(dot)Stepanov(at)inp(dot)nsk(dot)su, pgsql-bugs(at)postgresql(dot)org
Subject: Re: Bug #878: different format of float values in 7.2.and 7.3
Date: 2003-01-20 15:14:25
Message-ID: 2964.1043075665@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

pgsql-bugs(at)postgresql(dot)org writes:
> The following line:
> SELECT 1875/1000.0
> produces different results. In 7.2.3 it is:
> ?column?
> ---------------------
> 1.875

> while in 7.3.1 it is:
> ?column?
> ---------------------
> 1.87500000000000000

The above expression is taken as NUMERIC datatype in 7.3, rather than
FLOAT8 as it was in 7.2. To get the same output as before, try
SELECT 1875/1000.0::float8;

regards, tom lane


From: "Denis N(dot) Stepanov" <D(dot)N(dot)Stepanov(at)inp(dot)nsk(dot)su>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: Bug #878: different format of float values in 7.2.and
Date: 2003-01-20 15:24:29
Message-ID: Pine.LNX.4.33.0301202119450.10011-100000@Linda.inp.nsk.su
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

On Mon, 20 Jan 2003, Tom Lane wrote:

TL> pgsql-bugs(at)postgresql(dot)org writes:
TL> > The following line:
TL> > SELECT 1875/1000.0
TL> > produces different results. In 7.2.3 it is:
TL> > ?column?
TL> > ---------------------
TL> > 1.875
TL>
TL> > while in 7.3.1 it is:
TL> > ?column?
TL> > ---------------------
TL> > 1.87500000000000000
TL>
TL> The above expression is taken as NUMERIC datatype in 7.3, rather than
TL> FLOAT8 as it was in 7.2. To get the same output as before, try
TL> SELECT 1875/1000.0::float8;

Thanks. The main thing I understood is that it was done intentionally. Is there
a kind of document (mail message maybe) that describes the intentions to make
typecasts more strict and/or pecularities of such changes? I guess many users
faced with similar problems, probably it was already explained somewhere.

--
Regards,
Den.