You’re running into a numerical accuracy problem.
PHP has the maximum 32-bit integer value 2147483647
, in 64 bits the value 9223372036854775807
and above this will have a float, with possible loss of accuracy (see links at the end of the answer for more details).
It turns out that even though the float can display a reasonable number of houses, there is a setting for displaying these, which by default is 14
. Once this length is exceeded, the display will be "abbreviated".
More specifically, this is the directive:
php.ini file
precision 14
Link to the manual:
Directive precision
Using strings:
One possible solution is to use a string instead of number. Passing the value as string the output is textual, will be disregarded the numerical storage:
$p = '123456789111315171921'; // note as aspas aqui
$pyscript = 'C:\\Users\\python\\teste.py';
$python = 'C:\\Python34\\python.exe';
$run = shell_exec("$python $pyscript $p");
If you really need to work with large numbers, PHP has specific functions for this, in the BCMATH and GMP library (see links below).
Relevant links:
How to get the highest numeric value supported by php?
What is the maximum decimal places allowed in the PHP float?
Arbitrary accuracy in PHP with BCMATH
Arbitrary accuracy in PHP with GMP
The strange thing is that the argument passed saw shell will be string, not an integer. I ran the code here and did not have the problem cited in the question. The code is only the same or hid parts of it?
– Woss
@Anderson Carlos Woss, you tried to simulate with a number greater than or equal to 12345678910111213, because it may be a matter of Python version
– DaniloAlbergardi
@Bacco, I’m using PHP 7.0.4 x86
– DaniloAlbergardi