Bitmask is a technique used to isolate specific bits in a byte in order to work only on the desired ones. They are used in IP addresses to separate the network prefix and the host number for example.
Questions tagged [bitmask]
738 questions
0
votes
1 answer
converting decimal to hex using bitmask and shift in C
Ive been having trouble where the segmentation fault is in my code. I am trying to make a function that converts decimal numbers into hex numbers.
Also if I was to use: 15&15 would the number be 1111 or 15?
Here is my…

josh chang
- 13
- 1
- 2
0
votes
1 answer
Creating a histogram of edge image with concentric circles around one point [Matlab]
I have an edge image [gotten by applying canny edge detector]. On this I have a keypoint. I would like to get a histogram of the image with concentric (circular+radial) bins, similar to sectors in a CD or DVD, with the keypoint as the center.
I am…

Sharath Chandra
- 89
- 1
- 1
- 9
0
votes
5 answers
Best method to find out set bit positions in a bit mask in C
What would be the best way to identify all the set bit positions in a 64 bit bitmask. Suppose my bit mask is 0xDeadBeefDeadBeef, then what is the best way, to identify all the bit positions of the set bits in it.
long long bit_mask =…

Viks
- 760
- 4
- 12
- 26
0
votes
2 answers
Bit masking vs shifting (+java bytecode)
When working with IEEE754 floats I've found two ways of zeroing top 9 bits of a 32bit variable. Is any of them better than the other?
Java related addition: is there some list providing information about instruction efficiency? I've randomly found…

Vojtěch Hauser
- 56
- 1
- 7
0
votes
1 answer
Xquery "replace bitmask value for given index" issue in Oracle Service Bus
I'm trying to replace a 32 bit string variable. At first, all values "0".
$bitmask:="00000000000000000000000000000000"
I have some index values and should replace the values in these indexes with "1".
For instance, I have index…

Tolgay
- 38
- 3
0
votes
1 answer
SmartCTL bitmasking
HOwdie do,
I've searched all over Google and I have yet to find what this line does:
smartstat=$(($? & 8))
To put it in perspective, I'm attempting to directly access a the 3rd bit of an exit status.
SmartCTL by default uses 8 bits. When an error…

Jimmy
- 887
- 1
- 10
- 24
0
votes
3 answers
Using bit masking to set 0 to 1 and everything else to 0
How could I use bit masking to make all the bits in a number 1 if they were all 0, and all 0 if they were not?
Using an unsigned variable:
So, if I have 0000-0000, I would like that to become 1111-1111.
If I have 0101-0110 (or 0000-0001, or…

MirroredFate
- 12,396
- 14
- 68
- 100
0
votes
2 answers
Binary bit masking fetch different values in php
I want to fetch different values from one number by masking.I have explained it follow.
I have one number "1540104" and want to get related binary values and their related decimal values from it .
1540104
101111000000000001000
100000000000000000000…

Nilesh
- 197
- 3
- 11
0
votes
1 answer
Raspberry Pi bitmask for GPIO (OUT_GPIO and INP_GPIO)
I am trying to change the state (output/input) for more then one pin at the same time (with a bitmask).
The code for one pin is:
#define INP_GPIO(g) *(gpio+((g)/10)) &= ~(7<<(((g)%10)*3))
#define OUT_GPIO(g) *(gpio+((g)/10)) |= …

user2688893
- 21
- 2
0
votes
1 answer
How to doatomic CAS operation on two adjacent bits of a byte?
Say there is:
unsigned char byte = someValue;
What I need, is to perform an atomic CAS (compare and swap) operation on some two adjacent bits in byte, say the fourth and the fifth.
For sure, there is no way to address something shorter than a byte,…

Vahagn
- 4,670
- 9
- 43
- 72
0
votes
1 answer
How to store and retrieve 3-Bit number via bitmask?
Lets say I have a bitmask
enum ExampleMask
{
Attribute1 = 1 << 1,
Attribute2 = 1 << 2,
...
Attribute27 = 1 << 27
}
So I already use 27 of my 32 available bits.
I now want to be able to also store and retrieve a 3 bit unsigned…

xNidhogg
- 331
- 1
- 4
- 12
0
votes
2 answers
MySql Query Table of Masks
I have a table that is filled with a variety of "masks" such at this:
Type Mask1 Mask2 Mask3
0 fff fff ff
1 aff fff ff
2 aff fff 92
3 001 fff 00
And basically I want to…

bombadil
- 5
- 4
0
votes
2 answers
one sql parameter to give me 3 potential values
In my stored procedure I need a single parameter that will give me a potential of 3 values.
So I can do something like:
@p1 <-- my parameter
IF (@p1 ???) -- include users
SELECT * FROM USERS
IF (@p1 ???) -- include employees
SELECT *…

mrblah
- 99,669
- 140
- 310
- 420
0
votes
1 answer
C++ two dimensional array of bitsets
I have an assignment where we're tackling the traveling salesman problem.
I'm not going to lie, the part I'm doing right now I actually don't understand fully that they're asking, so sorry if I phrase this question weirdly.
I sort of get it, but not…

Corey Thompson
- 398
- 6
- 18
0
votes
1 answer
Extracting bit from a flow of bit string in Python
I have a binary file where a IP Packet was written. I have to create a Python program that has to validate each field in the IP Packet, so I'm trying to parse each field form the file (Ip Packet). The problem that I have is there are two fields that…

rocco
- 25
- 7