float conversion / presentation problem ?

From: Enrico Weigelt <weigelt(at)metux(dot)de>
To: pgsql-bugs(at)postgresql(dot)org
Subject: float conversion / presentation problem ?
Date: 2005-04-07 01:29:15
Message-ID: 20050407012915.GA18482@nibiru.borg.metux.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


Hi folks,

i've noticed an problem with conversion from real to float -
this produces ugly values. (in fact it seems to be real->float8)

> fxignal=# SELECT 12.345::real::float;
> float8
> ------------------
> 12.3450002670288

Maybe its not really an conversion problem, but an bug in sprintf(),
(there were some other float related bugs known in glibc), as these
examples let me suspect:

> fxignal=# SELECT 12.345::real::float::real;
> float4
> --------
> 12.345

> fxignal=# SELECT ((12.345::real::float8)-(0.345::float8))::real;
> float4
> --------
> 12

I noticed this behaviour on postgresql-7.4.1 and 7.4.3 on glibc-2.3.2

BTW: real is an alias to float4 ?

regards,
--
---------------------------------------------------------------------
Enrico Weigelt == metux IT service

phone: +49 36207 519931 www: http://www.metux.de/
fax: +49 36207 519932 email: contact(at)metux(dot)de
cellphone: +49 174 7066481
---------------------------------------------------------------------
-- DSL ab 0 Euro. -- statische IP -- UUCP -- Hosting -- Webshops --
---------------------------------------------------------------------

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Preethi 2005-04-07 03:51:33 BUG #1586: Rollback of installation during a silent install with -qn option
Previous Message John Smith 2005-04-06 23:55:05 Re: BUG #1547: CREATE TYPE AS error