Skip to main content

Questions tagged [bitwise-operators]

low-level, primitive operations that directly manipulate bit patterns and binary numerals

4 votes
3 answers
370 views

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 ...
The Fool's user avatar
  • 166
2 votes
6 answers
611 views

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 ...
Anon's user avatar
  • 3,633
2 votes
2 answers
250 views

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 ...
Tim's user avatar
  • 5,525
3 votes
5 answers
4k views

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 ...
p32094's user avatar
  • 187
1 vote
2 answers
2k views

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)...
Anon's user avatar
  • 3,633
0 votes
1 answer
252 views

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,...
LarsH's user avatar
  • 153
4 votes
1 answer
4k views

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 ...
Prime's user avatar
  • 143
4 votes
3 answers
773 views

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 ...
Sam's user avatar
  • 165
-5 votes
5 answers
279 views

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: ...
the_endian's user avatar
  • 1,152
1 vote
2 answers
570 views

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 ...
Martin Perry's user avatar
2 votes
3 answers
700 views

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 ...
the_endian's user avatar
  • 1,152
1 vote
1 answer
365 views

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 ~...
Anon's user avatar
  • 3,633
1 vote
3 answers
954 views

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 ...
Louis Thibault's user avatar
0 votes
1 answer
188 views

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, ...
foxtrotuniform6969's user avatar
83 votes
7 answers
17k views

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 ...
yoyo_fun's user avatar
  • 2,297

15 30 50 per page