byte[i] <<= 1; what does it mean ?
byte[i] <<= 1; what does it mean ?
if you have the complete program it is easy to explain but generally << means left shift example 1 << 2 means 1 in binary 00000001 << 2 gives 00000100 equal to 4.
You probably have encountered something like this before, i.e., you probably know that this:
is a "short hand" for:Code:x += y;
Likewise, this:Code:x = x + y;
has the same net effect as:Code:byte[i] <<= 1;
except that byte[i] is not evaluated twice, which could be important if the expression was:Code:byte[i] = byte[i] << 1;
where compute_i might be computationally expensive.Code:byte[compute_i()] <<= 1;
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
a <<= b means a = a << b
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler