Splitting large numbers in postgresql
I am working with numbers 18 decimal places, I decided to store this number as "NUMERICAL (36)" in the database
Now I want to represent it by doing the following division
select (5032345678912345678::decimal / power(10, 18)::decimal )::decimal(36,18)
result +5.032345678912345700
expected result +5.032345678912345678
It works if I use 16 decimal places precision
select (50323456789123456::decimal / power(10, 16)::decimal )::decimal(36,16)
Result 5.0323456789123456
Any idea how to work with 18 decimal places without losing information?
+3
source to share
1 answer