Hello,
I am trying the following:
int k,n,o;
n=3;
o=18;
k=o & (2^n);
I get an "Illegal Operand" error.
How else can I get a result of a bitwise AND of two integers?
Where is my mistake?
Haim
(2^n);
Returns a DOUBLE precision value since the power operator works with floating point. Just use a temporary variable if you want an integer power.
int k,n,o,z;
n=3;
o=18;
z = 2 ^ n;
k=o & z;
It works now.
Stupid of me to forget about the double.. :-[
Thanks for your help.
Haim
It happens, even to me! :o
I was trying to place text on a page using x,y and made the mistake of making x and y integers. The computer happily rounded down the coordinates to the next inch and made a mess of the output. I broke my own rule of always naming variables by type because iX and iY seemed silly.