May 01, 2024, 12:04:12 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


What am I doing wrong?

Started by Haim, April 05, 2007, 11:09:37 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Haim

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

Ionic Wind Support Team

 (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;
Ionic Wind Support Team

Haim

It works now.
Stupid of me to forget about the double..  :-[
Thanks for your help.

Haim


Bruce Peaslee

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.
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles