问题
I have encountered a topic regarding to calculation errors on Accuracy problems.
I end up with the following values in one of my queries in PostgreSQL:
1.0752688172043 (when using float)
1.07526881720430110000 (when using numeric)
1) So, for these values I think I should use numeric
data type in order to obtain result more accurately. Is that right?
2) What if the following values (assume that the rest digits after the last number is 0). In that case should I still use numeric
rather than float?
1.0752688172043 (when using float)
1.07526881720430000000 (when using numeric)
3) What about extra 0's when using numeric? For example, if the result is 0, it displays 0 with lots of digits instead of single digit. In that case is there a format for displaying single 0 in numeric
results?
来源:https://stackoverflow.com/questions/61711547/should-i-use-numeric-or-float-to-avoid-calculaton-prolems-in-postgresql