2,103 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
4
votes
1
answer
281
views
Implicit type casting within parenthesis and literals in C
The follow derives from the devkitpro 3ds filter audio example though it's not relevant to know exactly how the example works.
In short, consider this code:
size_t data_size = ...;
uint32_t data* = (...
1
vote
1
answer
63
views
Does the binary representation of a fixnum include a sign bit?
TL;DR:
In Emacs Lisp, is the sign of a fixnum part of its binary representation or stored in some metadata? What's the distinction between positive and negative fixnums?
Can the sign be switched in ...
1
vote
0
answers
125
views
Flag-setting shifts on AArch64? LSLS is not recognized. (Shift two registers together as a 128-bit integer)
I've been learning arm64 on a computer with a Mac M3 chip. The assembler (as) is not recognizing the lsls instruction which should be a logical shift left which sets the flags. (Also not lsrs.)
I am ...
3
votes
2
answers
194
views
Programme works but says "warning: integer constant is so large that it is unsigned", solution?
I am trying solve the problem posed in this question that asks << 1 operation be performed on a 64 bit number using NAND operation only and without using any arithmetic operation. My attempted ...
0
votes
0
answers
85
views
Which of these two bitwise expressions is faster, and is there an optimized alternative?
I have two bitwise expressions and need to figure out which one is faster. Also, if there are other ways to implement the same, but in a faster way than the given expression. I am using these ...
5
votes
2
answers
219
views
Inconsistent bitwise shifting result in C code
I'm writing a C program and need to create a bitwise mask that could potentially fill a computer word (64 or 32 bits) with all 1s. I found a bug in my code but I can't make sense of it because when I ...
2
votes
1
answer
257
views
Difficulty in understanding the logic behind a problem based on bitwise computations
As part of a test I was given, I am required to code the instructions below:
A function F(x) is defined over integers x >= 0 as:
F(x) = ∑ [(x | i) - (x & i)] (summation ∑ is over i),
with i ...
4
votes
2
answers
279
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() {
...
3
votes
1
answer
105
views
Avoiding undefined behavior when shifting in CUDA
In CUDA I regularly exploit the fact that the hardware does not limit the width of shifts.
This is unlike x86, where only the lower bits of the shift amount are taken into account.
Unfortunately I ...
0
votes
2
answers
248
views
How to rotate a 16-bit register in Z80
I have a value in a 16-bit register (say, HL). How do I rotate it left one or more times?
2
votes
1
answer
174
views
Optimization and Methods for Reversing Nibbles of a Byte
I'm currently studying encryption and I was coming up with ways of reversing the nibbles of a byte (ex. 0xF5 => 0x5F). I came up with this solution:
byte >> 4 | (byte & 0x0F) << 4
...
1
vote
1
answer
123
views
right shift not working correctly for large longs
when shifting bytes, there are some scenarios that do not seem to make sense, for example
printf("shifted bytes %llx\n",(((long long)1 << 63 ))>>1);
outputs c000000000000000, ...
3
votes
5
answers
160
views
MSP430FR5739 rotate bits in 16-bit unsigned integer
I am working on a project where I have to rotate bits in 16-bit unsigned integer using MSP430FR5739.
For example:
0111 0000 1101 1101 must become 1011 1000 0110 1110 after one shift to right.
I read ...
-1
votes
2
answers
146
views
Unexpected output from right rotate function
I was trying to solve the exercise that says
Exercise 2-7. Write the function rightrot(b, n) which rotates the integer b to the right by n bit positions.
and i did code it, here is the code
#include ...
4
votes
1
answer
134
views
Arithmetic shift-right integers with half rounding toward zero
I am looking for an efficient algorithm that computes arithmetic shift-right of integers that rounds to nearest integer with halfway rounding toward zero behavior. An answer can be a proper ...