floating point representation - Mailing list pgsql-hackers

From Hiroshi Inoue
Subject floating point representation
Date
Msg-id 3A8CDD3B.3FFC57C8@tpf.co.jp
Whole thread Raw
Responses Re: floating point representation  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-hackers
Hi all,

I have a question of PostgreSQL's floating point
representation.

create table t (fl1 float4, fl2 float4, fl3 float4);
insert into t values (1.234567, 1.23457, 1.23457);
select * from t;  fl1   |   fl2   |   fl3
---------+---------+---------1.23457 | 1.23457 | 1.23457
(1 row)

select * from t where fl1=fl2;fl1 | fl2 | fl3
-----+-----+-----
(0 rows)

select * from t where t where fl2=fl3;  fl1   |   fl2   |   fl3
---------+---------+---------1.23457 | 1.23457 | 1.23457
(1 row)

OK, fl1 != fl2 and fl2 == fl3 but

copy t to stdout;
1.23457 1.23457 1.23457

The output of pg_dump is same. Then
after restoring from the pg_dump 
output, we would get a tuple such
that fl1==fl2==fl3.

Is it reasonable ?

In addtion this makes a client library like ODBC
driver very unhappy with the handlig of floating
point data. For example, once a floating point
data like fl1(1.234567) was stored, MS-Access
couldn't update the tuple any more.

Is there a way to change the precision of floating
point representation from clients ?

Regards,
Hiroshi Inoue


pgsql-hackers by date:

Previous
From: Ryan Kirkpatrick
Date:
Subject: Re: Re: Recovery of PGSQL after system crash failing!!!
Next
From: Tatsuo Ishii
Date:
Subject: Re: Shouldn't non-MULTIBYTE backend refuse to start in MB database?