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
4 answers
Bitmasks: Initialize an int bitmask with a variable length list of ints AND int-ranges
Foreword: I find it annoying that an answer is marked as duplicate without actually checking if it solves one's problem. I've asked this question before, but didn't succeed. In particular, this question is not answered by Implementing Matlab's colon…

benjist
- 2,740
- 3
- 31
- 58
0
votes
1 answer
Simple way to calculate values in a bitmask?
Apologies - I'm not even sure I'm using the right terminology here.
I have a series of confidential documents and I'm creating a bitmask (?) to represent which of those documents a given user can view. (1 represents Doc1, 2 represents Doc2, 4…

Ernie Pantuso
- 3
- 3
0
votes
2 answers
Shift and masking in C
I have this problem. I have a payload that dinamically change its length. If I don't cut this payload, I will have also informations that are rubbish for me. So I want to cut the payload in base of my payload length.
I have this part of…

sharkbait
- 2,980
- 16
- 51
- 89
0
votes
1 answer
branchless bitwise operation
I'm looking for a branchless bitwise operation that can determine with a given mask :
Mask : 0xFF0000 Value : 0xAA0000 return : true
Mask : 0xFF0000 Value : 0xAA00AA return : false
Mask : 0xFF00FF Value : 0xBB00AA return : true
Mask : 0xFF00FF…

Anthony Catel
- 51
- 5
0
votes
4 answers
C# Storing categories in a value - Bitmasks
I am working on an application that have some categories. The aim is to store the categories in a value.
First, I choosed to store them in an int.
Categories : 0, 1, 2, 3...
Then I do a bitmask operation to find which category was selected.
But the…

MaT
- 1,556
- 3
- 28
- 64
0
votes
3 answers
Mask by n bytes
I struggle masking a uint64_t variable by N bytes. I do not know N but I know it is 8 or less. My current code looks like this:
// uint64_t n is given
uint64_t mask;
for( mask = 0x00; n; n--) {
mask = mask<<8 | 0xFF;
}
for building the mask.…

musicmatze
- 4,124
- 7
- 33
- 48
0
votes
3 answers
Shifting 4 bits using a single number
I have to write a method that takes in an integer as a parameter (0, 1, 2, or 3). I have to use that to create a bitmask with a 0. So, if the parameter is 0, than the bitmask will be FFF0, for 1: FF0F, 2: F0FF, 3: 0FFF. I am trying not to hardcode…

sparkonhdfs
- 1,313
- 2
- 17
- 31
0
votes
2 answers
What are possible ways of converting these bitmask definitions from pawn language to PHP?
Well, to clarify, pawn is a language that is pretty similar to C++. I'm programming an Admin Control Panel that requires bit mask permissions (in php) and I actually don't know if I converted the permissions properly (since it's something I have…

Ignacio Belhot Colistro
- 339
- 1
- 13
0
votes
1 answer
Bitmask functions
I'm writing a program to find if I can make a square with N sticks of N length.
Ive used Bitmask cause its easier for the big input I'm gonna put in there. For some reason, my backtracking code its not returning anything, in this line "bitmask & (1…

Giuseppe
- 490
- 1
- 11
- 27
0
votes
2 answers
Alternative to creating user permissions with bitmask
So the app we are writing has certain privileges a user can have, and at first we just made a simple bitmask and saved each privilege as a separate bit and stored the final value into our DB table as a long. But now we have so many permissions that…

Kevin DiTraglia
- 25,746
- 19
- 92
- 138
0
votes
1 answer
Write and use a function that takes a mask as an argument and returns a structure
I'm new to coding and I am trying to complete this assignment, but I can't get it to work:
Write and use a function that takes a mask as an argument and returns a structure.
Here is what I've done so far. Can someone help me understand what I'm…
0
votes
1 answer
Implementing bitmask verification in MS Access
I have a table Watchlist that contains a number of players and a flag to idenfity their offenses. I want to implement the flag as a bitmask. However, to catch wrong input at an early stage, I would like to check the bitmask against the table…

Ben
- 99
- 1
- 7
0
votes
3 answers
FileAttributes and bitmask problems
For some reason, when I try to check a file against FileAttributes.Normal, it seems like almost none of my files are showing up in my search. According to the API, that's because some other attributes are set. That's OK, I'll just need to search by…

Mac Sigler
- 189
- 1
- 15
0
votes
2 answers
C how to mask bits into char array
I have a char[16] array and i'm getting input from the user:
Input for example- 15, 21 ,23, -1
I need to set the bit value to '1' for the place 15,21 and 23.
-1 will finish the program.
Every char[16] array represent values from 0-127, that…

judith
- 805
- 2
- 12
- 17
-1
votes
1 answer
C and Win32: Getting non-documented return value from GetFileAttributesW() function
Language: C
Platform: Windows 10
Compiler: MinGW
I am obtaining a return value from the GetFileAttributesW() function (part of the Win32 API) equal to 17, which does not match any of the file attribute macros listed here, nor is it equal to the…

Gregor Hartl Watters
- 518
- 1
- 3
- 17