[Tex/LaTex] Bitwise operator in pseudo-code


I am translating a C++ program into pseudo-code using the algorithmicx package.

Do you know how I can represent the C bitwise operator like the shifts (<< and >>) ?

Until now I used power of 2 but it's not very convenient.

Best Answer

Pseudocode has a different purpose compared to the actual programs. It should convey ideas, not implementation, and as such should be as close to the natural language as possible. Therefore I think it's not good to introduce programming language-specific syntax in the algorithm listing.

I suggest one of these options:

  • continue using algorithmicx and select a human-readable name for the operation: \State $x \gets \Call{ShiftLeft}{x, 3}$;
  • use the listings package and typeset the actual C++ program with comments.