473,396 Members | 2,055 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Bitmasks

MrPickle
100 100+
When using bit masks, how do you do "not bitmask", not sure how to explain it so:

How could you do this in bitmasks: if(!something)
Oct 14 '08 #1
5 3107
Banfa
9,065 Expert Mod 8TB
When testing if a bit (or a set of bits) is or isn't set you use the AND bitwise operator.
Oct 14 '08 #2
MrPickle
100 100+
Yes, but how would I check is it's NOT something.

I know that the logical not is !, is this also the bitwise not?
or do I have to do (bitmask & bitmask2) ? false : true;
Oct 14 '08 #3
Banfa
9,065 Expert Mod 8TB
No bitwise NOT is ~ it is also called bitwise 1's complement.

However logical NOT might suit your purpose better or even testing against a specific value, do you understand fully the output of logical NOT given its possible range of input values?

I suggest you work through a simple example on paper.
Oct 14 '08 #4
MrPickle
100 100+
I know that !true isn't the same as false (I think), but that's it.
Oct 14 '08 #5
donbock
2,426 Expert 2GB
Mask off the unwanted bits, then compare what's left against zero -- either equal to zero or not equal to zero, depending on what sense the test should have.
Oct 14 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Jaakko Holster | last post by:
Lets run following code: ------- snip ------ class Perm { static $read = bindec('001'); static $write = bindec('010'); static $delete = bindec('100'); }
12
by: Matthew Wilson | last post by:
I'm playing around with genetic algorithms and I want to write a function that mutates an integer by iterating across the bits, and about 1 in 10 times, it should switch a zero to a one, or a one...
0
by: Aaron Straup Cope | last post by:
Hi, Included below is a copy of a message I sent to the py-tutor list. It didn't garner much in the way of a solution and it was suggested that this list might be helpful. Thanks, ...
1
by: Andrey Brozhko | last post by:
Hi I need to represent custom type system (ints, bytes, chars, enums, bitmasks, arrays and some other types) in xml. It is easy to see how to represent enums in xml (using xs:enumeration), the...
20
by: GS | last post by:
The stdint.h header definition mentions five integer categories, 1) exact width, eg., int32_t 2) at least as wide as, eg., int_least32_t 3) as fast as possible but at least as wide as, eg.,...
26
by: Radith | last post by:
Hi All, I have got this task which I cant get my head around: It asks how I would store information: I just want to get an opinion from the group: So here's the question: " You have been...
20
by: cozzzy | last post by:
Hello, I have an unsigned int variable, which is really a set of bits. So what I need, is to check specific bit state: on/off (0 or 1). For example, I need to know is the 16-th bit is on. How...
2
by: vijlak | last post by:
Hi All, I would like to know how to accomplish the following: First, I would give an example of MFC. Let's take the CreateButton styles. So, if some one wants to create a Button they...
1
by: SoftwareTester | last post by:
I have following namespace Mine.Bits { public static class Bits {
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.