Will Newton <will@gbdirect.co.uk> writes:
> I have attached some SQL which produces what to me, at least, is
> rather unexpected results. Selecting real columns into double
> precision columns loses some precision. Is this expected or documented
> anywhere?
You shouldn't be surprised; this is a fundamental behavior of floating
point arithmetic anywhere.
There isn't any "loss of precision" per se --- the value represented in
the float8 column is the same as what was in the float4 column. The
difference is that the float8 output routine is programmed to print
about 15 digits of precision whereas the float4 routine prints no more
than 6. So you get to see the fact that the stored value wasn't really
20.2 but only something close to it.
If you find this surprising maybe you should be using type "numeric".
regards, tom lane