bitwise-and

What does the bitwise code "$n & ($n - 1)" do?

What does this code mean and what are other ways accomplish the same without using bit shifting? if ($n & ($n - 1)) ...

How might I set the bottom 3 bytes of a 4-byte long while leaving the top byte intact?

Relevant code is this: typedef unsigned long int chunk_head; typedef struct malloc_chunk { // Contains the size of the data in the chunk and the flag byte. chunk_head head; // Deliberately left unsized to allow overflow. // Contains the payload of the chunk. unsigned int data[]; }; And just as an example...

Bitwise AND on 32bit Integer

How do you perform a BitWise AND on 2 32 bit integers in C#? Related: Most common C# bitwise operations ...

java help bitwise operations

System.out.println( s + ", long: " + l + ", binary: "); System.out.print(" "); for(int i = 63; i >= 0; i--) if(((1L << i) & l) != 0) System.out.print("1"); else System.out.print("0"); System.out.println(); ...

"Bitwise And" and Left-Padding in C++

I have a macro that looks something like this: Foo(x) ((x - '!') & 070) If I call the following code: Foo('1') => 16 However, if I call the following code: (('1' - '!') & 70) => 0 So my question is, what's going on here? Why does x & 070 compute to x but x & 70 compute to 0? My guess is that the extra 0 on the left is forcing 6...

Bitwise operation error ?

I'm developping a site for fun and I'm trying to implement a directory access control based on bitwise operators. I've defined GUEST = 1, GROUP1 = 15 and GROUP2 = 23 If I compare echo (23 & 1); // print 1 but if I define GUEST, GROUP1 and GROUP2: define('GUEST', 1); define('GROUP1', 15); define('GROUP2', 23); // and then ...

Relocation overflow when performing bitwise AND (SPARC Assembly)?

I am trying to perform a bitwise AND on a register, as a bitmask to remove the most significant bit (which happens to be bit 16 when counting from 0). However, when I try to compile my code using gcc, it gives me the following error messages: Assembler messages: 19: Error: relocation overflow My guess is that this has something to do w...