Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Boolean Operations...?

Author
Message
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 26th Dec 2008 10:27
Okay, I'm in need of performing a bit of boolean math.

What I'm wanting to do is AND two numbers together.

I was surprised to see that it actually performed correctly in DBP, but in C++ it doesn't work.


Here's what I'm wanting:

100
-AND-
001

This should obviously be FALSE, because when we and them together, all bits should be 0.

DBP did this fine by using the following code:


Here's the C++ code I tried to use with this:


This returns TRUE in C++. What I'm thinking that it's doing is looking at the 4... saying "That's a True value", then looking at the 1, saying that "That's a True value also!" then when it ands both "true" values together it gets a "true" output. This isn't what I want.


I've searched google for as long as I can stand only finding nothing. Any searches for "Boolean operations" or anything relating to "boolean", gives me boolean data type pages, or the same boolean operators that I've been trying to use.



Does anyone know how to do what I'm after here?


The one and only,


Kevin Picone
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 26th Dec 2008 11:30
AND, OR are bitwise operators so to obtain the same behaviour you'd use &,| in C/C++

eg


Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 26th Dec 2008 11:44
Ahhhhh, thank you veryvery much, Kevin.


The one and only,


Login to post a reply

Server time is: 2024-11-25 09:37:31
Your offset time is: 2024-11-25 09:37:31