Questions tagged [bitwise-operators]
low-level, primitive operations that directly manipulate bit patterns and binary numerals
57 questions
4votes
3answers
308views
what is the term for a integer variable containing bit fields
If I have a variable that is intended to to be used with bitmasks, to retrieve values, i.e. bit fields and flags, what is the academic term for such a variable? If the (bit) fields are a analogous to ...
2votes
6answers
611views
What is the viability of engineering an integral type with values ranging from -1 to 254? Do types like this even exist?
In software engineering, often developers will utilize three different states of a signed integer, as a trilean: This tends to be quite typical: -1 - Represents something akin to a null pointer, as in ...
2votes
2answers
250views
Are bitwise operators in C used both for bit operations and for operations for integer or some C types?
In C, Bitwise logical operators &, |, ^ is used for selecting bits in a word. Bitwise shifting operators >> and << can be used for implementing multiplication and division between ...
3votes
5answers
4kviews
Why is the bitwise AND of 1 and any even number equal to 0?
I’m curious as to why the bitwise AND of any even number with 1 is equal to 0? I’ve looked at the binary representations of an odd number and 1, and have found that the following is always true for ...
1vote
2answers
2kviews
In C++, Why do bitwise operators convert 8 or 16 bit integers to 32 bit?
Is there a logical reason why the integer is upgraded to 32+ bits? I was trying to make an 8bit mask, and found myself a bit disappointed that the upgrade will corrupt my equations. sizeof( quint8(0)...
0votes
1answer
251views
How to implement FNV-1(a) in SQLite?
Moved I originally posted this on SoftwareEngineering because that's where this related question was; but having looked into the Help in detail, I think my question is more on-topic for stackoverflow,...
4votes
1answer
4kviews
Semantics of simulating a 64bit integer with two 32bit integers (hi, lo)
I am working in a system which only supports 32bit integers, in order to have a 64bit (unsigned) integer I decided to simply use two 32bit integers with one being the upper 32 bits (hi), and the other ...
4votes
3answers
773views
What's the purpose of multiplying by 1024x1024?
I'm working with an old C module that was originally ran on Power PC architecture and compiled with gnu 3.0.6 I'm porting it to run in a VS2012 project on Intel hardware. The module creates a 3D ...
-5votes
5answers
279views
Do decimal equivalents to binary number values hold significance in software programming?
It seems as though in software engineering, we care more about these "on and off switch" usages of binary numbers more than the actual values of them numbers... For example, say I have the number: ...
1vote
2answers
570views
C++ - BitVector logic
I have implemented a simple bit vector class. However, I have some problems with understanding, how to push data to it. In a standard vector, push_back inserts new element et the end. A similar ...
2votes
3answers
700views
What effects does memory space have on bitwise shifts?
It is true that the bitwise left shift operation (shl) doubles the value of the integer being shifted. However, when constrained to a finite space, such as 8 bits for example, left shift will begin to ...
1vote
1answer
365views
How to understand and design functions with enumeration arguments that work in tandem with bitwise operators in C++ and Qt?
In the C++, there are 6 bitwise operators: Symbol Operator & bitwise AND | bitwise inclusive OR ^ bitwise XOR (eXclusive OR) << left shift >> right shift ~...
1vote
3answers
954views
How can I query, increment & decrement arbitrary-length integers encoded into a bit-array?
I'm in the process of implementing a counting Bloom filter. This data structure is defined as a bit-array and a "width" parameter, W. The bit array stores unsigned integers, whose size is determined ...
0votes
1answer
188views
Best practices for reading dynamic byte streams: is line-by-line comparison with a mask the best way?
I receive sensor data as a binary stream of bytes. This stream is not always the same length, and does not include the same data set each time. If the sensor did not send a field, it is simply absent, ...
83votes
7answers
17kviews
Why are bit masks called "masks" and what purpose do they serve?
Why are "bit masks" called like this? I know that they are mainly used for bitwise operations and the usage of bit masks is more efficient than the usage of separate variables. However my question ...