IonicWind Software

Aurora Compiler => Coding Help - Aurora 101 => Topic started by: Haim on April 05, 2007, 11:09:37 AM

Title: What am I doing wrong?
Post by: Haim on April 05, 2007, 11:09:37 AM
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
Title: Re: What am I doing wrong?
Post by: Ionic Wind Support Team on April 05, 2007, 12:33:51 PM
 (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;
Title: Re: What am I doing wrong?
Post by: Haim on April 05, 2007, 10:29:33 PM
It works now.
Stupid of me to forget about the double..  :-[
Thanks for your help.

Haim

Title: Re: What am I doing wrong?
Post by: Bruce Peaslee on April 06, 2007, 08:37:20 AM
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.