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
How to decode hexadecimal bitmask with php?
I have a database with a field containing a bit mask, and I have a hex bit mask list which looks like this:
2^8 256 = Type 1
2^9 512 = Type 2
2^0 001 = Type 3
2^4 016 = Type 4
2^1 002 = Type 5
2^5 032 = Type 6
I'm trying to "decode" (not sure of…

Tony
- 121
- 2
- 13
0
votes
1 answer
Code only working on iOS 7
Hi I've been making a game with the SpriteKit framework and I set a collision bit mask when 2 objects collide. One of those objects, let's say the object A, can have 2 states: black or normal so when the two objects collide and the A object is on…

Facundo Schiavoni
- 451
- 7
- 17
0
votes
1 answer
Bit math and masks correlation to numbers
Good evening,
I am trying to correlate the required values to the values that needs to be sent to an I2C device, and I am having issues with the bit math and masking.
My range goes from -15 to 15, so does the range of the device.
Example of required…

Deskwizard
- 5
- 1
0
votes
1 answer
Swift collision not working. I think something is wrong with my code in didBeginContact
I've been working on a game that has to perform a test every time my test node contacts with my check node. As these two nodes are the only nodes that will be checking for collision in the game, I decided to use this method to initiate my test.
The…

John Imyeob Kim
- 3
- 1
0
votes
0 answers
Check that a bitmask flag is zero
I'm getting data from a server. The first bit indicates whether a message was read or not read: 1 for "read" and 0 for "not read". The second bit says whether the message was edited or not.
So I'm trying to read the statuses:
typedef…

Maria
- 755
- 1
- 11
- 29
0
votes
1 answer
Converting a struct of integers into a bitmask
Is it possible (if so, how) to convert a struct of integers into a bitmask. One bit for each integer (0 if the int is 0, otherwise 1). For example
struct Int_List_t
{
uint64_t int1;
uint64_t int2;
uint64_t int3;
uint64_t int4;
}…

Nigel Armstrong
- 3
- 2
0
votes
2 answers
Merging 13 bits array into an array of unsigned char
I'm writing an algorithm that compresses data (LZSS) and it requires me to have two 13-bit values which I'll have to later merge together.
In some cases, however, I don't need 13 bits; 8 are enough.
For this purpose I have a structure like…
0
votes
2 answers
How to create BufferedImage with BITMASK Transparency?
The BufferedImage class implements Transparency, which has three values:
OPAQUE means no transparency.
TRANSLUCENT means every pixel has an Alpha value between 0 and 1.
BITMASK means every pixel is either opaque or completely transparent.
I can…

Leif Sabellek
- 173
- 1
- 9
0
votes
2 answers
Bitmask as member enum with default parameter
I can't figure out how to implement a bitmask parameter for my class.
Specifically my CreateMenuDlg function
I've searched google quite a bit, finding all sorts of forum questions that ask about bitmasks, bitfields, etc. and everyone posts minimal…

Numerials
- 3
- 2
0
votes
1 answer
how to store exclusive OR boolean as bitmask
I am working with a interface where most flags are implicitly false when not set, but some parameters have an explicit 'x-not-set' flag, so that either flag can be passed in but never both and in some cases, neither should be passed in. I think the…

Anthony
- 36,459
- 25
- 97
- 163
0
votes
2 answers
Bitwise AND operation on UInt8 enum
Having the following enumeration
enum ColliderType: UInt8 {
case Hero = 0b1
case GoblinOrBoss = 0b10
case Projectile = 0b100
case Wall = 0b1000
case Cave = 0b10000
}
I'm trying to do something very simple:
let combined =…

Shai
- 25,159
- 9
- 44
- 67
0
votes
0 answers
Checking for collision in SWIFT
I have two objects that I want to collide: ball and centerBlock.
I created physics bodies for each and wrote the following:
ball.physicsBody!.categoryBitMask = BodyType.ballCategory.toRaw()
ball.physicsBody = SKPhysicsBody(circleOfRadius:…

Tommy
- 140
- 8
0
votes
0 answers
How to use bitmask operations in SQL
I'm already quite familiar with the concept of bitmasks, and also with the bitwise operators used to modify them. However, I have one specific problem that I can't solve. Here's the problem:
I have a large number of relatively large bitmasks…

Arshia001
- 1,854
- 14
- 19
0
votes
1 answer
C++ Bitmask 72bit variable and cut off leading and trailing zero's - Help please
I have a 72 bit unsigned variable and I am only interested in 24 bits. The variable is split into the 34 bits / 24 bits / 14 bits. The bit mask works fine but I would like to dump the 34 zero's at the front and the 14 zero's at the back and store…

Hearny
- 17
- 3
0
votes
1 answer
Bitmask understanding in C program
I have a program that my professor gave me for a HW, and I want to see if any of y'all can explain me how bits work. Note: I don't want you guys to give me the answer; I want to learn so if you guys can explain me how this work would be awesome so I…
user3977404