Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [bitwise-operators]

Operators which are used to perform manipulation at bit-level.The programming languages are Byte oriented whereas the hardware is bit oriented.Therefore, being able to operate on bit level can be very important in programming,especially when the program directly interact with the hardware.

0 votes
0 answers
28 views

Optimizing Code with Bitwise Operators : How Does That Really Work? [closed]

How do bitwise operators (like AND, OR, XOR, left shift, and right shift) manipulate binary data at the bit level, and what are some practical examples of their usage in optimizing code performance or ...
Prinan-99's user avatar
0 votes
2 answers
21 views

Performance of BIT_AND vs relational table

I have a case where users may have access to some content with subscriptions, it's not video streaming but I will write an example with that for easier understanding: users in "basic" ...
Uto dev's user avatar
  • 11
0 votes
0 answers
29 views

Representing an 8-digit hexadecimal as a long [duplicate]

I am writing a Java program that performs bitwise operations on bites in a data stream. I have been given test values in the form of 8-digit hexadecimal strings, which I have converted to base 10 and ...
T. J. Foster's user avatar
5 votes
1 answer
122 views

Logical shift right without dedicated shift instruction

I am working with an assembly language that does not contain either multiply, divide, or bit-shift instructions. I am aware that a left bit-shift can be achieved by just adding the same number to ...
Kestrel's user avatar
  • 73
-1 votes
3 answers
110 views

C segfault question: if one of two inputs is null, return the other

I have a function that takes two strings and returns another string (if you must know, its my implementation of strjoin). Now, I want to make it so that if one of the input strings is NULL, it will ...
Cab the Kid's user avatar
0 votes
1 answer
24 views

Dask: In-place Modification with Boolean Indexing Causing Unexpected Behavior

I would like to do an in-place bitwise operation on my dask array i, with a mask cover it. MVE: import dask.array as da i = da.full((10,10),fill_value=4) c = da.ones(i.shape, dtype=bool) c[:,0] = ...
COW's user avatar
  • 1
0 votes
1 answer
82 views

Randomizing the choice of ports (uint8_t bitmask) efficiently

Assuming I have 4 ports that may be on or off, and are represented by the LSBs of a uint8_t mask, meaning 0b00001001 means ports 0, 3 are on. Given a number between 0-3 (which represents the ...
Dan's user avatar
  • 39
0 votes
1 answer
90 views

How can I perform bitwise operations in python exactly how javascript would?

I am trying to write the following javascript function in python exports.hash = u => { u += 0xe91aaa35; u ^= u >>> 16; u += u << 8; u ^= u >>> 4; let a =...
Jabir Nurul Haque's user avatar
0 votes
2 answers
45 views

Understanding the use of bitwise-operator in ternary-operator

I'm just learning how to code and while studying sorting algorithms I was asked to "see if you can combine the two lines in your if and else blocks into one line to make your code look a little ...
Sergio Ruiz Sánchez's user avatar
0 votes
0 answers
74 views

Problem understanding a bitwise XOR operation code in rust

I have the following code, the purpose of it is to find 14 distinct letters in a string of letters. It does it by using a left shift and XOR operator, I don't fully understand why the left shift is ...
MarinaF's user avatar
  • 75
0 votes
3 answers
56 views

Is there a general approach for optimizing bitwise expressions that distinguish two arbitrary sets of integers?

For context, I need to write a test for an integer between 0 and 7 inclusive, that evaluates to true for {1,3,4,6} and false for {0,2,5,7}. I thought for a couple minutes about whether there might be ...
gbromios's user avatar
  • 420
1 vote
1 answer
100 views

Clang-tidy-18 `hicpp-signed-bitwise` "use of signed integer" false positive?

This might turn to be a stupid question but I really don't understand why clang-tidy is complaining here. Consider the following config: # .clang-tidy --- FormatStyle: file WarningsAsErrors: '*' ...
Slav's user avatar
  • 357
1 vote
1 answer
49 views

Why does bit vector a = [01101001] encode set A = {0, 3, 5, 6}?

I'm reading Computer Systems: A Programmer's Perspective and I don't understand why does bit vector a = [01101001] encode set A = {0, 3, 5, 6}? I did some googling but haven't find anything useful. I'...
not-a's user avatar
  • 75
0 votes
2 answers
46 views

convert left shifted LSB bits to 1

I need to convert LSB 0 to 1 in left shift: x=5; int num = 0x02;//0b00000010 shiftVal = num << x;// 0b01000000 shiftVal should convert to 0b01011111
alex's user avatar
  • 7,815
-1 votes
1 answer
55 views

How to remove option from bit wise operation [closed]

I am working in a WPF app where I have some Items checked, I am trying to clear the checked items and reset it in the for loop if the is check is true. Using ' fruit.FruitType = NewFruitType.None;' ...
Dev's user avatar
  • 1,806

15 30 50 per page
1
2 3 4 5
207