I have a C # code that looks like this:
uint a = 0x9E3779B9;
a += (uint)(url[k + 0] + (url[k + 1] << 8) + (url[k + 2] << 16) + (url[k + 3] << 24));
After this code, a == 228 452 386
Now I am trying to translate this C # code into PHP, but in PHP the number does not overflow the same:
$a = 0x9E3779B9;
$a += ($url[$k+0] + ($url[$k+1] << 8) + ($url[$k+2] << 16) + ($url[$k+3] << 24));
After this code, $ a == 4,523,419,682
In both cases, "url" is treated as an array of ascii values. Returns the same results until $ a is added to the result of the second row. At this point, C # uint overflows to ~ 228 million. PHP becomes smart and comes up with the right answer.
But I want a crowded answer that C # gives. What should I do?
source
share