PHP 5.6.12 - Return of integer incorrect -
previously have been developing app using php 5.6.7 in linux, i've switched windows environment using wamp 64 bit , upgraded php 5.6.12 , been running few issues. 1 issue in backend php have array of integers. when print return front prints return array console different format. is:
$permission->fk_org_id = [24053826281537536,24051529749102626,111]; print json_encode($permission->fk_org_id);
returns following console:
0:24053826281538000 1:24051529749103000 2:111
why happening?
those numbers large fit in (32-bit) integer. interpreted float, see documentation:
if php encounters number beyond bounds of integer type, interpreted float instead. also, operation results in number beyond bounds of integer type return float instead.
a float has precision of 14 significant digits, that's why see zeroes.
unfortunately, php on windows not support 64 bit integers, according this answer:
on windows x86_64, php_int_max 2147483647. because in underlying c-code, long 32 bit.
however, linux on x86_64 uses 64bit long php_int_max going 9223372036854775807.
Comments
Post a Comment