Re: Proposal for resolving casting issues

From: "Zeugswetter Andreas SB SD" <ZeugswetterA(at)spardat(dot)at>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Bruce Momjian" <pgman(at)candle(dot)pha(dot)pa(dot)us>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Proposal for resolving casting issues
Date: 2002-09-19 08:40:46
Message-ID: 46C15C39FEB2C44BA555E356FBCD6FA4961E90@m0114.s-mxs.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


> "Zeugswetter Andreas SB SD" <ZeugswetterA(at)spardat(dot)at> writes:
> > 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.
>
> Lose what precision? It seems silly to imagine that the product of

Have you seen my example ? If calculated in float4 the result of
1.00000000000001*1000.0-1000.0 would be 0.0, no ?

> a numeric and a float4 is good to more digits than there are in the
> float4. This is exactly the spec's point: combining an exact and an
> approximate input will give you an approximate result.

Does it actually say how approximate the result needs to be, or is it simply
approximate by nature that one part was only approximate ?
Do they really mean, that an approximate calculation with one float4 must be
calculated in float4 arithmetic ? If you e.g. calculate in float8 it would still
be an approximate result and thus imho conform.

> (Unless of course the value in the float4 happens to be exact, eg,
> an integer of not very many digits. But if you are relying on that
> to be true, why aren't you using an exact format for storing it?)

Probably because the approximate is more efficient in storage size,
or the designer knew he only wants to store 6 significant digits ?

> > Informix does the calculations in numeric, and then converts the result
> > if no casts are supplied (would do set float4col = float4(float4col::numeric * numericcol)).
>
> I am not sure what the argument is for following Informix's lead rather
> than the standard's lead; especially when Informix evidently doesn't
> understand numerical analysis ;-)

It was only an example of how someone else does it and was why I asked what
other db's do. I would e.g. suspect Oracle does it similarily.
Please, someone check another db !

Andreas

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Karel Zak 2002-09-19 09:14:58 to_char(FM9.9) bug fix
Previous Message Christopher Kings-Lynne 2002-09-19 07:16:36 Postgres 7.2.2 Segment Error