Comment 1 for bug 370360

Revision history for this message
wouter bolsterlee (wbolster) wrote :

> The 'numeric' column type in a PostgreSQL result is now converted to
> float. However, 'numeric' doesn't necessarily mean it is a floating
> point value. Doing a SUM() over some BIGINT column also reports a
> 'numeric' type, and by converting it to a float I've lost precision
> information.

I don't see how one could possibly lose precision in this case. A mathemathical property of integer numbers is that addition, subtraction and multiplication (but not division!) of two integers will always result in an integer. I suspect PostgreSQL somehow detects/assumes that summing over BIGINT may cause numerical overflow, and converts the numbers to floats (which can keep higher numbers).

It could well be that I'm overlooking something here, though. If so, please tell me how (and why) you lost numerical precision in the case you described.