Dividing large numbers in postgresql

Viewed 444

I am working with numbers of 18 decimals, I have decided to save the number as a "NUMERIC (36)" in database

Now I want to present 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 a precision of 16 decimals

select (50323456789123456::decimal  / power(10, 16)::decimal )::decimal(36,16)

result 5.0323456789123456

Any idea how to work with 18 decimals without losing information?

1 Answers
Related