Questions tagged [bitmask]

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.

738 questions
0
votes
1 answer

bitwise operator on android : why large numbers are not equals

suppose I write some very simple tests in an android app working on simulator (marshmallow, OSX 64 bits) whith logcat output: Log.i("test","long int = "+17301768L); Log.i("test","long int = "+(1<<3 | 1<<8 | 1<<19 | 1<<24)); Log.i("test","long int =…
0
votes
2 answers

The overlapping sub problems in bitmask dynamic programming

I am trying to learn bit masking with dynamic programming but I'm failing to understand the overlapping sub problems for a case. Can someone please explain how the sub problems overlap based on any example they feel fit for explaining easily?
Shababb Karim
  • 3,614
  • 1
  • 22
  • 35
0
votes
0 answers

MSP430 external port interrupt

I am trying get an external interrupt and blink an LED, but I get an error like: pragma vector = accepts numeric arguments or "unused_interrupts" but not PORT_VECTOR The code is as follows: int main(){ // Stop Watch Dog Timer WDTCTL = WDTPW…
0
votes
1 answer

I am trying to scale up a bit mask, but while it works at lower numbers, it falls apart at higher ones

As of right here, R6 contains an integer I want to print out in binary. EndLoop AND R4, R4, #0 ADD R5, R5, R6 ;This moves my INT to R5 AND R1, R1, #0 AND R2, R2, #0 LD R2, Count NOT R2, R2 ADD R2, R2, 1 ;This is an…
Luke
  • 483
  • 2
  • 6
  • 13
0
votes
2 answers

Bitmask 0b1 parsing back to int

Is there a way in Java SDK 1.8 to parse a String like "0b1" back to its integer value ? I tried with Integer.parseInt but it fails. Same question with this String "0b1111_1101" ? Maybe there's something in Eclipse.JDT to eval this as a java…
Fab
  • 14,327
  • 5
  • 49
  • 68
0
votes
0 answers

Trying to find how many hidden files and user executable in C from code that does something similar as "ls" in unix

So what I am trying to do is do the same thing that "ls" command in unix though. So here is code the code that does it. But what I want to do is add a global variable that will count the number of hidden files and the number of user executable…
hiquetj
  • 410
  • 1
  • 8
  • 23
0
votes
2 answers

Assign contactTestBitMask to

In SpriteKit I wish to assign the contactTestBitMask value to a set of values. This is the normal way: sprite.physicsBody?.contactTestBitMask = ColliderType.goal.rawValue | ColliderType.greyBox.rawValue meaning my sprite notifies me when it comes…
jtmwanakhu
  • 623
  • 1
  • 6
  • 17
0
votes
4 answers

Why does bit shifting a negative number doesn't work?

Here is my code: long x1 = -123; long y1 = -312; long x2 = -111; long y2 = -112; long packed = x1 | y1 << 15 | x2 << 30 | y2 << 45; Debug.log("x1:" + ((packed) & 0b111111111111111)); Debug.log("y1:" + ((packed >> 15) &…
Gintas_
  • 4,940
  • 12
  • 44
  • 87
0
votes
1 answer

Swift Sprite kit Collision Bitmask

I was wondering if anyone would be able to offer me some help with using 3 nodes, I understand if I just have 2 nodes E.g. body A and body B but I'm struggling with adding a third body, I hoped it was as simple as body C but that wasn't the…
0
votes
1 answer

How do I compare (AND) two strings which represent a binary mask in mysql?

I have a table in mysql which stores (among other columns) a bitmask as a string, for example: 000100 I'd like to perform a query which will AND these fields together to provide a result that shows when any two mask positions are both true. As an…
JYelton
  • 35,664
  • 27
  • 132
  • 191
0
votes
1 answer

Bit manipulation of a single bit of an integer or bit masking

I would like to define a single bit of a register or a variable. For example: #define Pin5 (5th bit of portA) //assuming porta is a 16 bit data type. How can I define a single bit of a variable so that I can toggle that bit easily and make my…
Sam
  • 51
  • 1
  • 5
0
votes
2 answers

What should my constant mask value be for radix sort?

I was given a problem for one of my CS courses where I have to program a LSD radix sort that can sort unsigned integers (+ or -). It is given that the values to be sorted are 32-bit integer values. The stipulation is that my mask must be a constant…
0
votes
1 answer

Masking a Register Using Its Pointer - AVR Ports

I'm programming a Simon Says game with a microprocessor (atmega32) using some LEDs and buttons. I am trying to store the pointers to a PORT register in an array, which a function will use to mask the register (to turn the pins on to light the LED)…
D. Lau
  • 3
  • 2
0
votes
1 answer

Steps to create certain bit masks?

I'm looking for a general way to create a bit mask using shifts and bitwise operators and to be wary of overflow from shifting left ex. 0x80000000 would be something like (~0 >> 31) << 31, correct me if I'm wrong More specifically 0xAAAAAAAA and…
Crowning
  • 167
  • 1
  • 2
  • 10
0
votes
1 answer

Box2d filter (maskbits and categorybits)

I searched multiple times but I'm not sure why my contact filtering is not working. I used libgdx to create this simple game. The code is as follows: public static final short BORDER_CATEGORY_BITS = 0x0001; public static final short…
Major Ben
  • 139
  • 1
  • 10