Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-bugs by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group