2

I make a simple division using php. Then I test the result in a windows machine running apache and in a linux machine running apache as well.

 WINDOWS: 1/15 returns 0.066666666666667
 LINUX: 1/15 returns   0.0666666666667

Any suggestions why this is happening? Is it php, apache or OS?

dev
  • 1,367
  • 1
  • 10
  • 28

2 Answers2

3

In general, the size of a PHP float is platform-dependent, so you should not make any assumptions if you want portable code.

However, the difference you see might also be caused by a difference in configuration settings. The printed value of a floating-point value depends on the precision setting.

Related:

Community
  • 1
  • 1
Heinzi
  • 159,022
  • 53
  • 345
  • 499
0

php config. floating point precision settings. number of decimal places option.

Dave
  • 3,224
  • 2
  • 22
  • 40