I saw some strange results:
postgres=# select '1.1'::numeric = '1.1'::float8;
?column?
----------
t
(1 row)
postgres=# select '1.1'::numeric = '1.1'::float4;
?column?
----------
f
(1 row)
When I looked into it, I saw that the numeric is being cast to a float8,
making the first statement trivially true.
Why does the cast go from numeric to float if that direction loses
precision? One reason is because float supports +/- infinity, but that
seems more like convenience than a good reason. Is there another reason?
Have we considered adding +/- infinity to numeric so that it can
represent every float value? That might make the numeric hierarchy a
little cleaner and less surprising.
Regards,
Jeff Davis