Set precision for floats in php for 15 numbers after comma

1k Views Asked by At

Servus, I have a problem with float numbers in PHP. My number is

$cosVQ = 0.907424504992097 

but when I do some math operations $cosVQ, I will receive different results in Javascript and PHP. Or for example wen I do echo I will receive only 0.9074245049920. What am I doing wrong?

2

There are 2 best solutions below

0
On BEST ANSWER

Ok I found answer for my question, which works as I wanted: ini_set('precision', 15);

1
On

You could use number_format:

echo number_format($cosVQ, 15);