How to work with high precision decimal places in PHP

I am trying to create a website with a database with PHP and data stored in a PostgreSQL database (PDO access), and I will need to store and process decimal numbers with high precision (in some cases more than 20 digits after the decimal).

I plan to use the NUMERIC or DECIMAL data types in my database to store this data to maintain the required high levels of accuracy.

What is the best way to use PHP to (1) access these values ​​and (2) do basic arithmetic on such high-precision numbers?

I do not want to just use float, as this data type may be inaccurate.

Thanks!

+7
source share
1 answer

Check out the GNU Multiple Precision and BC Math Extensions.

+11
source

All Articles