Saturday, 18 February 2017

hiphop - What does `





I was looking at this article about facebook's HipHop Virtual Machine (HHVM) when I noticed this line:



$u_bytes =

$p_bytes = 100 << 20;


I tested it by running echo 100 << 20; and the value was 104857600. What does << 20 do?






Edit



Based on the answers it's a bitwise operator (bit shift [left]). Example:




100       = 000000000000000000001100100
^ `<< 20` moves this bit 20 bits to the left
104857600 = 110010000000000000000000000

Answer



This is a bit shift left.



You can learn more on how it works in PHP directly on PHP Manual: http://php.net/manual/en/language.operators.bitwise.php


No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...