From: | "Zeugswetter Andreas SB SD" <ZeugswetterA(at)spardat(dot)at> |
---|---|
To: | "Bruce Momjian" <pgman(at)candle(dot)pha(dot)pa(dot)us>, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Proposal for resolving casting issues |
Date: | 2002-09-18 16:01:05 |
Message-ID: | 46C15C39FEB2C44BA555E356FBCD6FA4887A1E@m0114.s-mxs.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
> > Note that if you write, say,
> > set numericcol = numericcol * 3.14159;
> > my proposal would do the "right thing" since the constant would be typed
> > as numeric to start with and would stay that way. To do what you want
> > with a float variable, it'd be necessary to write
> > set numericcol = numericcol * float4col::numeric;
Yes, that is the case where the new behavior would imho not be good (but you
say spec compliant). I loose precision even though there is room to hold it.
> > which is sort of ugly; but no uglier than
> > set float4col = float4col * numericcol::float4;
Informix does the calculations in numeric, and then converts the result
if no casts are supplied (would do set float4col = float4(float4col::numeric * numericcol)).
Would be interesting what others do ?
Test script:
create table atab (a decimal(30), b smallfloat, c decimal(30), d smallfloat);
insert into atab values (1.000000000000001,100000.0,0, 0);
update atab set c=a*b-b, d=a*b-b where 1=1;
select a*b-b, b, c,d from atab;
(expression) b c d
1e-10 100000.0000000 1e-10 1e-10
I hope this test is ok ?
It still seems to me, that numeric should be the preferred type, and not float8.
Andreas
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2002-09-18 16:26:41 | Re: Proposal for resolving casting issues |
Previous Message | Tom Lane | 2002-09-18 15:15:27 | Re: Backend crash (long) |