As per recommendations, I always use the numeric
type for any column supposed to hold a sum of money.
When inserting such values (or updating them), I always use high precision math functions in my application (PHP "BC Math").
This results in the fields getting values such as:
-1494.744565020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
I view them later in pgAdmin 4 and it's very annoying to see the long series of pointless zeroes, when it should be just:
-1494.74456502
There is no meaning with storing/representing all those zeroes like that. I'm not fully sure if this is PG or pgAdmin's doing, actually.
Either way, I want to avoid it. How do I prevent numeric values from being stored with pointless zeroes?
(Of course, I don't want less precision -- I'm just talking about zeroes that literally have no meaning and thus should be automatically cut off from the right until they hit a non-zero digit.)
Is PG for some reason storing these numeric numbers like this? If so, why?
numeric
has the range of "up to 131072 digits before the decimal point; up to 16383 digits after the decimal point", so any client is within its rights to display all of them.numeric(13,2)
?