Postgres row_to_json precision for numeric type
0
I am using the row_to_json function to convert a table row to a json object. There are a few columns in the table that are of type numeric which contain float values. When row_to_json returns the json, values like 9.98 becomes 9.98000000000000043 or 6.30 becomes 6.29999999999999982 in these numeric columns. Is there a way to impose precision at the json creation function? There are no other data issues in the table which are affecting other modules. Changing the column type to numeric(12,2) etc. is not possible since the table has over 2 billion rows(the table would be locked for 30+hours) and would affect other production modules. --update-- I should have made the question a little bit clearer with the use case. row_to_json is used in a trigger to audit updates in the DB. The json result is stored ...