Jon Lapham <lapham(at)extracta(dot)com(dot)br> writes:
> Is the preferred way to return the average of ::float4 values to
> explicitly cast the returned value of avg() to ::float4?
Yeah, if you want it to float4 precision. The internal arithmetic
is always done in float8 to try to minimize cancellation problems.
> main_v0_8=# select avg(0.01::float4);
> avg
> ---------------------
> 0.00999999977648258
> (1 row)
This isn't really any different from
regression=# select 0.01::float4::float8;
float8
---------------------
0.00999999977648258
(1 row)
regards, tom lane