0

When I'm dividing,

echo 50.3228679581385 / 100;
Output:0.50322867958139

It should be 0.503228679581385 . Is there any way to avoid default round up?

Giri Annamalai M
  • 810
  • 9
  • 24

2 Answers2

2

Yes, there's an INI setting for that, where 14 is the default value:

; The number of significant digits displayed in floating point numbers.
; http://php.net/precision
precision = 14

Increase to 15 or more, as necessary. Also works at runtime like this:

ini_set('precision', 15);
Narf
  • 14,600
  • 3
  • 37
  • 66
1

It's not default round up, it's because of the precision limit on double.

iamnoten
  • 231
  • 2
  • 7