can mingw do bitwise operations? Topic is solved

If you are using wxDev-C++ for your wxWidgets design, please ask your questions here instead of in IDE Related.
Post Reply
ouch67
Earned some good credits
Earned some good credits
Posts: 135
Joined: Sun Mar 23, 2008 12:09 am

can mingw do bitwise operations?

Post by ouch67 »

I have this code:

Code: Select all

   if(type & tradeable > 0)
    {
        CheckBox3->SetValue(true);
    }
    else
    {
        CheckBox3->SetValue(false);
    }
both vars are int.

when type equals 1 and tradeable equals 2 why the freak does the if statement flag the result to be higher than 0?

on my calculator 1 and 2 equals 0...
Sof_T
Can't get richer than this
Can't get richer than this
Posts: 864
Joined: Thu Jul 28, 2005 9:48 pm
Location: New Forest, United Kingdom
Contact:

Post by Sof_T »

Don't you mean to use the && operator and not the & operator?

Sof.T
The home of Sof.T http://www.sof-t.site88.net/
Author of Programming with wxDevC++
http://sourceforge.net/projects/wxdevcpp-book/
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Post by doublemax »

> has higher precedence than &, you need to use brackets

Code: Select all

if( (type & tradeable) > 0)
Use the source, Luke!
ouch67
Earned some good credits
Earned some good credits
Posts: 135
Joined: Sun Mar 23, 2008 12:09 am

Post by ouch67 »

sure does.

didn't see that, thanks!
Post Reply