The bitand in Matlab


To be honest, I am not a fan of Matlab but I sometimes have to use matlab to plot nice figures for publications.

If you are a ‘traditional’ C-like programmers, you must be very familiar with the bit and and conditional (logic) and, which is often used as ‘&’ and ‘&&’ respectively.

However, this is so what different in Matlab. In Matlab, the single and double & both corresponds to conditions however the double ones uses a ‘short-circuit’ evaluation which means if the first boolean expression is false, then the second expression will not be evaluated. The single &, however, will evaluate both disregard their values.

In order to do a bit ‘and’ (which applies to two integers), you have to use the function bitand. The same principle goes to bitor (instead of | or ||), and bitxor, if you want to do bit ‘or’, or exclusive ‘or’.

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading...
198 words
Last Post: How To Add a Virtual Host on Apache2 Under Ubuntu Server?
Next Post: How to Create a Ranking Page in WordPress Based On GD Star Rating Plugin?

The Permanent URL is: The bitand in Matlab

Leave a Reply