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,377
  • 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
  • 167,459
  • 57
  • 363
  • 519
0

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

Dave
  • 3,280
  • 2
  • 22
  • 40