Re: Fw: [pgadmin-support] (Bug) Numeric fault calculation - Mailing list pgsql-bugs

From Kevin Grittner
Subject Re: Fw: [pgadmin-support] (Bug) Numeric fault calculation
Date
Msg-id 1366749993.89747.YahooMailNeo@web162903.mail.bf1.yahoo.com
Whole thread Raw
In response to Fw: [pgadmin-support] (Bug) Numeric fault calculation  (Kanitchet Vaiassava <kanichet@hotmail.com>)
List pgsql-bugs
Kanitchet Vaiassava <kanichet@hotmail.com> wrote:=0A=0A> [division and some=
 math functions using the numeric type can=0A> sometimes have a result whic=
h the numeric type cannot represent=0A> exactly]=0A=0AYeah, you can use a s=
impler example:=0A=0Atest=3D# select '1'::numeric / '3'::numeric;=0A=A0=A0=
=A0=A0=A0=A0=A0 ?column?=A0=A0=A0=A0=A0=A0 =A0=0A------------------------=
=0A=A00.33333333333333333333=0A(1 row)=0A=0Atest=3D# select '3'::numeric * =
('1'::numeric / '3'::numeric);=0A=A0=A0=A0=A0=A0=A0=A0 ?column?=A0=A0=A0=A0=
=A0=A0 =A0=0A------------------------=0A=A00.99999999999999999999=0A(1 row)=
=0A=0A> So I think this problem should be solve? or at least, it should=0A>=
 be note in document for other developer to be more careful.=0A=0AYeah, the=
re should probably be something in the docs to indicate=0Athat not all rati=
onal numbers (and certainly no irrational or=0Aimaginary numbers) can be st=
ored as a single numeric value without=0Aloss of precision.=0A=0AIt might b=
e interesting to create a "rational" type which would=0Ainternally hold two=
 numeric values, and which would be capable of=0Adoing what you want.=A0 I'=
m not sure that the demand is sufficient to=0Aback the development of it, t=
hough.=A0 (Is there a convention for how=0Ato indicate the repeating part o=
f a decimal fraction when you can't=0Adraw a line over those digits?)=0A=0A=
In the absence of such a type, you might want to arrange your=0Acalculation=
s such that any division or square root calculations=0Aare done last.=A0 Th=
at way the effect of the truncation of the=0Arepeating (or not) infinite de=
cimal fraction won't be multiplied by=0Aa later phase of the calculation.=
=0A=0A-- =0AKevin Grittner=0AEnterpriseDB: http://www.enterprisedb.com=0ATh=
e Enterprise PostgreSQL Company

pgsql-bugs by date:

Previous
From: roberto.menoncin@netspa.it
Date:
Subject: BUG #8107: How to downgrade database from 9.2.3 to 8.4 ?
Next
From: Bruce Momjian
Date:
Subject: Re: BUG #8107: How to downgrade database from 9.2.3 to 8.4 ?