-
as seen on Stack Overflow
- Search for 'Stack Overflow'
What are some real world use cases of the following bitwise operators?
AND
XOR
NOT
OR
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
Hi
Could someone translate this statement into pseudo-code (or just plain english)?
var c:uint = 0xFF << 24 | r << 16 | g << 8 | b;
>>> More
-
as seen on Game Development
- Search for 'Game Development'
I've got the following code in a shader:
// v & y are both floats
nPixel = v;
nPixel << 8;
nPixel |= y;
and this gives me the following error in compilation:
shader.fx(80,10): error X3535: Bitwise operations not supported on legacy targets.
shader.fx(92,18): ID3DXEffectCompiler::CompileEffect:…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
I need to make transparency, having 2 pixels:
pixel1: {A, R, G, B} - foreground pixel
pixel2: {A, R, G, B} - background pixel
A,R,G,B are Byte values
each color is represented by byte value
now I'm calculating transparency as:
newR = pixel2_R * alpha / 255 + pixel1_R * (255 - alpha) / 255
newG…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
The challenge is to find the fastest way to determine in C/C++ the length of a c-string using bitwise operations in C.
char thestring[16];
The c-string has a max size of 16 chars and is inside a buffer
If the string is equal to 16 chars doesn't have the null byte at the end.
I am sure can be done…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
How can I perform bitwise operations on strings in ruby?
I would like to do bitwise & a 4-byte string with a 4-byte long hex such as ("abcd" & 0xDA2DFFD3). I cannot get the byte values of the string. Thanks for your help.
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
Hi,
Can you please explain the below lines, with some good examples.
A left arithmetic shift by n is
equivalent to multiplying by 2n
(provided the value does not
overflow),
while
a right arithmetic
shift by n of a two's complement value
is equivalent to dividing by 2n(2…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
I've been given the task of porting Java's Java.util.Random() to JavaScript, and I've run across a huge performance hit/inaccuracy using bitwise operators in Javascript on sufficiently large numbers. Some cursory research states that "bitwise operators in JavaScript are inherently slow," because internally…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
For the life of me, I can't remember how to set, delete, toggle or test a bit in a bitfield. Either I'm unsure or I mix them up because I rarely need these. So a "bit-cheat-sheet" would be nice to have.
For example:
flags = flags | FlagsEnum.Bit4; // Set bit 4.
or
if ((flags == FlagsEnum.Bit4))…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
How can I quickly extract two rows of a scipy.sparse.lil_matrix and apply bitwise operations on them? I've tried:
np.bitwise_and(A[1,:], A[2,:])
but NumPy seems to want an array type according to the documentation.
>>> More