Skip to main content
Filter by
Sorted by
Tagged with
4 votes
1 answer
281 views

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* = (...
Nil A Curious Programmer's user avatar
1 vote
1 answer
62 views

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 ...
vmonteco's user avatar
  • 15.9k
1 vote
0 answers
124 views

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 ...
Matt Chuckle's user avatar
3 votes
2 answers
193 views

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 ...
uran42's user avatar
  • 469
0 votes
0 answers
85 views

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 ...
ahmed 's user avatar
  • 11
5 votes
2 answers
216 views

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 ...
A Retha's user avatar
  • 53
2 votes
1 answer
257 views

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 ...
Giogre's user avatar
  • 1,664
4 votes
2 answers
267 views

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() { ...
user8683582's user avatar
3 votes
1 answer
105 views

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 ...
Johan's user avatar
  • 77.4k
0 votes
2 answers
243 views

I have a value in a 16-bit register (say, HL). How do I rotate it left one or more times?
user avatar
2 votes
1 answer
174 views

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 ...
Legended's user avatar
  • 151
1 vote
1 answer
120 views

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, ...
user20695956's user avatar
3 votes
5 answers
158 views

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 ...
user19402326's user avatar
-1 votes
2 answers
146 views

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 ...
Haru Hoshizora's user avatar
4 votes
1 answer
133 views

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 ...
ksaa's user avatar
  • 83
1 vote
3 answers
194 views

I'm using the PIC18F47-Q18 Curiosity HPC Development Board and the MPLAB X IDE v6.20. The goal is to store the 10 bit value from the analog output into the 8 bit PWM. Depending on the justification of ...
Ivan's user avatar
  • 13
2 votes
1 answer
108 views

I have a snippet of code below that checks whether a register value is set. # define My_register_array(index) (*((P2VAR(uint32, AUTOMATIC, APPL_VAR))Group_register(index))) /*eg: Group_register(...
user2986042's user avatar
  • 1,300
0 votes
2 answers
133 views

I want move some of bit toward right in javascript, but I found result was not right because I wrote a test program by C language to contradistinction. I spend whole day who had't found correct way. ...
Viweei's user avatar
  • 31
0 votes
1 answer
77 views

I've been following along to Cave of Programming's C++ for Complete Beginners on Udemy, and in lesson 67 he goes over bitshifting to output certain colour pixels in an SDL window. There's a certain ...
Aaron Kelly's user avatar
1 vote
2 answers
97 views

I have a function implemented which reverses the bits in a number. The number of bits in the number to be reversed can vary. However, of course it must be shifted to the left at the end to align with ...
Engineer999's user avatar
  • 4,159
-3 votes
1 answer
181 views

I'm trying to understand how the right shift (>>) operator works in JavaScript, especially when dealing with negative numbers. I know that the left shift operator (<<) effectively ...
Aditya Basak's user avatar
1 vote
2 answers
118 views

After more than 20 years off, I started to get back into coding again, and started re-learning C++ (a language I practically never used, I used to be an Object Pascal man). So, I consider myself a ...
AlexisVanWien's user avatar
1 vote
1 answer
227 views

This is my code. When I change the mantissa, exponent, and sign to 23, 8, and 1 respectively in order to represent a 32 bit number, my code works. However when the values are changed to represent the ...
Neel Varma's user avatar
0 votes
0 answers
80 views

Consider the below code: std::string g_CharTable = "stjkloptrew23456mncv891TZUIOPAS"; std::uint32_t value = 123456789 std::string hash; for (std::size_t i = 0; i < 5; ++i) { ...
Jean-Milost Reymond's user avatar
0 votes
1 answer
175 views

converting the 16 bit data to 8 bit and then reversing it back to 16 bits Module Module1 Sub Main() ' Original 16-bit data Dim originalValue As UShort = &HA91 ' Split ...
nyl's user avatar
  • 13
5 votes
1 answer
432 views

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
5 votes
2 answers
186 views

This is a very specific problem and I haven't heard back from the author, so I thought I would throw this out and see if my sanity is intact or not. This is in regard to this video regarding DMA on a ...
robert bristow-johnson's user avatar
0 votes
2 answers
98 views

I am working on several home automation projects with PIC12F675. To maximize portability, I am using bit-shift operations to map GPIOs, like this: // Hardware Mapping #define pressure_pin (1<<0)...
Nelson's user avatar
  • 333
0 votes
1 answer
63 views

This code reduces a unsigned 32 bit integer into a 8bit as per our requirement. Currently this operation takes almost 2.1 mili sec to complete. Can it be optimized to complete at least under 0.9 mili ...
Sujan SM's user avatar
-1 votes
1 answer
81 views

I wanted to know if anyone knows what would be faster and why. do: this.data[byte] |= 1 << bitIndex; Or do1: const BIT_MASKS: Uint8Array = new Uint8Array([1, 2, 4, 8, 16, 32, 64, 128]); this....
Sleep's user avatar
  • 37
0 votes
0 answers
46 views

I'm writing a program in assembly that simulates multiplication via iterative addition. I have the algorithm done, and for my first test case, I set my multiplicand to 50. Upon transferring this value,...
Hydro's user avatar
  • 1
1 vote
1 answer
443 views

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
  • 376
6 votes
1 answer
278 views

I have a Go program that performs bit shifting and division operations on the length of a string constant, but the output is not what I expect. Here's the code: package main import "fmt" ...
grzhan's user avatar
  • 91
0 votes
0 answers
41 views

I'm a programmer, wondering about the impact of byte ordering on bit shift operations. I've come back around to this topic time and time again but never found an answer to it: Why does everyone hype ...
Ben C.'s user avatar
  • 11
0 votes
1 answer
59 views

In our C Code we are Bitshifting a 1: if(posizion_LED_MODUL == 3) //This statement is True, and this LED is Switched correctly { PORTC |= (1 << led); } This somehow messes ...
user24159369's user avatar
-2 votes
2 answers
77 views

I'm running a simple program to understand how bit shifting operates in C. The expression (temp << n) / 2^n is indeed equivalent to temp as I see. Reasoning this, it seems that the left shift ...
StanWarne's user avatar
0 votes
0 answers
98 views

I have a function like: func splitNumberByDecimals(u uint256, dec uint) (intFraction, decFraction uint){ ... } The task is to extract an unsigned number, and the number of decimal places for this ...
JobWeek's user avatar
  • 29
1 vote
1 answer
116 views

So, I saw the following line index >>= 1 and I was wondering what did it mean. I did a little research and found out it was bitwise operations, but I had to simulate a few scenarios in my head ...
Alexander Nedelchev's user avatar
1 vote
0 answers
119 views

Since python has no limit on the number of bits for storing an integer, how exactly does it perform bitwise operations on integers? How many bits does it really store an integer in? RealPython claims ...
Rajdeep Sindhu's user avatar
1 vote
1 answer
93 views

Why does the following program code output the value -32 to the console? int num = 0xFFFFFFE; for(int i=0; i < 4; i++) { num = num << 1; System.out.println(num); } The program produces ...
MAGistr's user avatar
  • 119
9 votes
3 answers
798 views

In C, many operations employ bit shifting, in which an integer literal is often used. For example, consider the following code snippet: #define test_bit(n, flag) (1UL << (n) & (flag)) As ...
Feng. Ma's user avatar
  • 323
1 vote
1 answer
136 views

Ones Counter Implement (Structural Level Modeling) I am implementing a One's Counter that will count for the number of ones of an 8-bit binary value. State Diagram S0: start = 0 ↓ S1: R1 = ...
Cheng En Chung's user avatar
1 vote
1 answer
120 views

I am trying to calculate floating point addition with only using bit shifts and logical ands(&) and ors(|). I am aware that built in floating point addition is more practical, but this is needed ...
Bobascotch's user avatar
0 votes
1 answer
326 views

I am trying to implement the booth's multiplication algorithm in ARM assembly language. Algorithm 2: Booth’s Algorithm to multiply two 32-bit numbers to produce a 64-bit result Data: Multiplier in V , ...
CyberFrenzy's user avatar
3 votes
1 answer
179 views

I know that >>> is unsigned shift-right, and since byte in Java is signed 8-bit then -1 will be represented as 1111 1111. As a result, for the code below: byte b = (byte) -1; b >>>= ...
K_K's user avatar
  • 33
0 votes
2 answers
597 views

I've got this task: dividePower2 Compute x/2n, for 0 ≤ n ≤ 30. Round toward zero. Argument 1: x Argument 2: n Examples: dividePower2(15,1) = 7 dividePower2(-33,4) = -2 This is what I've got so far ...
Aidan M's user avatar
  • 47
0 votes
2 answers
519 views

So I have this problem where ANDS R1, R2, R3 and to assume the flags are initially N=0 Z=0 C=0 V=1 Q=0 R1: 0000C5BF H R2: 0000A0F9 H R3: is 00000000 H I have to examine the end results of the ...
user788888's user avatar
0 votes
1 answer
472 views

I am trying to bit-shift a bigint like so: let foo = BigInt(420) << 32; but I am getting the JavaScript Error: Operator '<<' cannot be applied to types 'bigint' and 'number'. How do I bit-...
Cale McCollough's user avatar
0 votes
1 answer
113 views

Here is a visual of what I want to have happen 5 bit sliding window In words, I want a sliding window of 5 bits. I need to store a history of 5 events within a single byte. I'm using the 5 most ...
crose72's user avatar
0 votes
2 answers
120 views

I need to bit shift x by b, where b can be positive (shift left), zero (nop), or negative (shift right). C bit shift doesn't handle negative shifts. Can I define an inline func or macro to do this? ...
SRobertJames's user avatar
  • 9,377

1
2 3 4 5
43