3,108 questions
2 votes
3 answers
184 views
Bitwise operations act outside of type width in C; Compiler Bug or Within Spec?
The following derives from this question but is distinct Consider the following code sample; uint32_t *value = malloc(sizeof(uint32_t)); *value = 0xAAAABBBB; int16_t *subset = (int16_t*) (value); ...
2 votes
2 answers
223 views
Bitwise division in C : Programme seems to work for other numbers but when the divisor is 0 it returns 11 for no apparent reason
I am trying to solve the problem posed in this question which asks that division of two numbers be performed in a bitwise manner. So, I wrote the following functions. sum() adds two numbers. larger() ...
5 votes
3 answers
285 views
Finding the bigger number using bitwise operation in C
I am trying to write a computer programme that will take two numbers from the user as inputs and will print the bigger number using bitwise operation. I want it to end the programme and return 1 if ...
0 votes
0 answers
28 views
Detecting overflow in two’s complement multiplication by 2 – which bits need to be checked
Given a number with a width of n bits representing a signed number in two's complement, what is the minimal number of bits that need to be checked and which ones, in order to know whether there will ...
4 votes
2 answers
252 views
Shift "<<" and bitwise "&" operators precedence issue. Why it doesn't compile?
This code doesn't compile. It seems like the compiler (VS) is interpreting the expression as: (std::cout << ul1) & (ul2 << std::endl) #include <iostream> int main() { ...
-1 votes
1 answer
57 views
Assembly: Character type checking
So I'm practicing disassembling on an C program that checks if the user given serial number fulfills the requirements. The program manually checks each character from the serial number, executing the ...
-2 votes
1 answer
37 views
Salesforce Bitwise Comparison
I have a field containing an int that represents flags 0 = No error 1 = Error 1 2 = Error 2 4 = Error 3 8 = Error 4 so if I have a value of 5, I know it is Error 1 and Error 3 I need to add custom ...
-2 votes
1 answer
98 views
Using bitwise operations to simulate an N-length hash table: is space complexity O(1) or O(n)? [closed]
I am solving a problem that requires O(1) space complexity to check for duplicate numbers. I wanted to use a hash table, but due to the O(1) space constraint, I used bitwise operations. However, I ...