bitwise-operators

How to make an AND operation on 2 numbers in MATLAB

Hey, I want to know how to perform an and operation on 2 numbers in MATLAB ex :- x = 31 '11111' ; y = 23 '10111' ; If I use the AND operation on this 2 numbers I will get z = x AND y z will be 23 due to AND operation How can I do this in MATLAB ? ...

practical applications of bitwise operations

What have you used bitwise operations for? why are they so handy? can someone please recommend a VERY simple tutorial? ...

Represent BitWise AND,OR,SHIFT Operations in PseuodoCode

How Can I represent bitwise AND, OR Operations and Shift Operations using PsuedoCode? Please Hep me ...

The opposite of 2 ^ n

The function a = 2 ^ b can quickly be calculated for any b by doing a = 1 << b. What about the other way round, getting the value of b for any given a? It should be relatively fast, so logs are out of the question. Anything that's not O(1) is also bad. I'd be happy with can't be done too if its simply not possible to do without logs or ...

Fastest way to loop every number with conditions

Given a 64 bit integer, where the last 52 bits to be evaluated and the leading 12 bits are to be ignored, what is the fastest way to loop every single combination of 7 bits on and all other bits off? Example: First permutation: 0[x57]1111111 Last permutation 00000000000011111110[x45] Where 0[xn] means n off (zero) bits. Speed is...

Reading and interpreting data from a binary file in Python

Hi, i want to read a file byte by byte and check if the last bit of each byte is set: #!/usr/bin/python def main(): fh = open('/tmp/test.txt', 'rb') try: byte = fh.read(1) while byte != "": if (int(byte,16) & 0x01) is 0x01: print 1 else: print 0 ...

JavaScript byte logic

What does this JavaScript code mean? flag &= ~CONST Is it append, prepend, intersection or something else? ...

Why use the Bitwise-Shift operator for values in a C enum definition?

Apple sometimes uses the Bitwise-Shift operator in their enum definitions. For example, in the CGDirectDisplay.h file which is part of Core Graphics: enum { kCGDisplayBeginConfigurationFlag = (1 << 0), kCGDisplayMovedFlag = (1 << 1), kCGDisplaySetMainFlag = (1 << 2), kCGDisplaySetModeFlag = (1 << 3), ...

& vs && and | vs ||

I know the rules for && but what is & and | how to evaluate? Please explain me with an example. ...

Performing a logical not ! using only bitwise operations.

Possible Duplicate: Check if a number is non zero using bitwise operators in C. Hello everyone, I am working on a project and I need a little help with a function. We need to write a function that performs the logical not, !, using only the following bitwise operators: ~ & ^ | + << >> I'm not even sure where to begin. ...

i_mode file type value of 16

I have been told that I need to add a new file type to linux. File types are declared in fs.h Relevant part posted here: * File types * NOTE! These match bits 12..15 of stat.st_mode * (ie "(i_mode >> 12) & 15"). */ #define DT_UNKNOWN 0 #define DT_FIFO 1 #define DT_CHR 2 #define DT_DIR 4 #define DT_BLK ...

How can I do a bitwise-AND operation in VB.NET?

I want to perform a bitwise-AND operation in VB.NET, taking a Short (16-bit) variable and ANDing it with '0000000011111111' (thereby retaining only the least-significant byte / 8 least-significant bits). How can I do it? ...

bitwise operations on vector<bool>

Hi! what's the best way to perform bitwise operations on vector<bool>? as i understand, vector<bool> is a specialisation that uses one bit per boolean. I chose vector<bool> for memory saving reasons. I know that there are some problems with vector<bool> but for my needs it's apropriate. now - what's the most performant way of aplying ...