-
Notifications
You must be signed in to change notification settings - Fork 205
Closed
Description
quote from #287 (comment)
@flexarts with respect to the ints: it even goes wrong with some 32-bits ints. Everything >= pow(2,31) results in either a negative value or zero. Either V8 itself or the extension still treats Windows or PHP7 on Windows as 32-bits. This is not true anymore for PHP7 on 64-bits Windows:
http://php.net/manual/en/language.types.integer.php
I simplified your testscript a little bit to play around with different values:
<?php
$int = pow(2,32) - 1; // >= pow(2,31) => negative, >= pow(2,32) => 0
// test 1 (Exchange ints natively)
$v8 = new V8Js('PHP');
$v8->p2 = $int;
var_dump($v8->p2);
$result1 = $v8->executeString('var res = parseInt(PHP.p2);"p2 = " + PHP.p2 + ", res = " + res;');
// test 2 (Exchange ints as STRING)
$v8 = new V8Js('PHP');
$v8->p2 = (String)$int;
var_dump($v8->p2);
$result2 = $v8->executeString('var res = parseInt(PHP.p2);"p2 = " + PHP.p2 + ", res = " + res;');
$result = array('native' => $result1, 'string' => $result2);
print_r($result);
?>
Result (in PHP 7.1 nts x64):
D:\phpdev\php71nts.x64>php v8js.php
D:\phpdev\php71nts.x64\v8js.php:7:
int(4294967295)
D:\phpdev\php71nts.x64\v8js.php:13:
string(10) "4294967295"
Array
(
[native] => p2 = -1, res = -1
[string] => p2 = 4294967295, res = 4294967295
)
Metadata
Metadata
Assignees
Labels
No labels