Reputation: 1
Below is the left shift code in c# and php7.
Why and how to match PHP output with C# output?
Thanks in advance.
var ret = 0xFFFFFFFF;
var a=ret << 8;
Console.WriteLine(a);
4294967040
where as
$ret = 0xFFFFFFFF;
$a=$ret << 8;
echo $a;
1099511627520
Upvotes: 0
Views: 80
Reputation: 1319
Don't use the var keyword, use explicitly long instead of it:
long ret = 0xFFFFFFFF;
long a = ret << 8;
Console.WriteLine(a);
The var will use a 32 bit integer not a 64 bit integer.
Upvotes: 1