bit-shift Questions
1
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 i...
Protostele asked 4/7 at 16:41
2
Solved
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...
Vicissitude asked 1/7 at 2:32
6
Solved
I am trying to do assignment: "Find the number of bits in an unsigned integer data type without using the sizeof() function."
And my design is to convert the integer to bits and then to count them...
Doggy asked 12/8, 2016 at 16:25
1
Solved
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"...
Superstar asked 17/4 at 7:17
3
Solved
I was working on an algorithm of sub sequences.
What is the meaning of the statement:
if (counter & (1<<j))
within the context of the program below:
void printSubsequences(int arr[], int...
Distinguished asked 13/1, 2017 at 7:40
3
Solved
float length = 32.32f;
long i = *(long*)&length ; // casting a float pointer to a long pointer...
i >>= 1; // right shift i but 1 ... or div by 2
length = *(float*)&i; // is this nece...
3
Solved
I want to create a 64-bit barrel shifter in verilog (rotate right for now). I want to know if there is a way to do it without writing a 65 part case statement? Is there a way to write some simple c...
Calkins asked 25/9, 2011 at 4:8
4
Solved
I've been reading the classic Hacker's delight and I am having trouble understanding the difference between logical shift right,arithmetic shift right, and rotate right. Please excuse if the doubt ...
Portia asked 22/6, 2017 at 9:6
8
Solved
Are shift operations O(1) or O(n) ?
Does it make sense that computers generally require more operations to shift 31 places instead of shifting 1 place?
Or does it make sense the number of operati...
Anacreontic asked 31/1, 2012 at 17:5
9
I need to extract specific part (no of bits) of a short data type in C.
For Example I have a binary of 52504 as 11001101000 11000 and I want First 6 ( FROM LSB --> MSB i.e 011000 decimal 24) bits...
Conqueror asked 10/4, 2012 at 14:5
3
Solved
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...
Eccentricity asked 15/1 at 16:46
11
Solved
I've been attempting to learn C in my spare time, and other languages (C#, Java, etc.) have the same concept (and often the same operators)...
At a core level, what does bit-shifting (<<, >...
Subfamily asked 26/9, 2008 at 19:47
4
Solved
Before flagging this as a duplicate, please read below, and check my code * my updated code!
So my problem is that, I have to implement Java/JavaScript '>>>' (Unsigned Right Shift / Zero-fill Righ...
Enfield asked 14/12, 2016 at 3:23
4
I am currently helping teach a Computer Programming class. (I am in my Senior Year in High School, TA-ing for my Computer Programming teacher.) Right now the students are learning about bit-wise op...
Monied asked 6/8, 2015 at 9:44
3
Solved
I want to convert the code if this answer to Kotlin: https://mcmap.net/q/430222/-using-public-key-from-authorized_keys-with-java-security
I pasted this into Intellij:
private int decodeInt() {
r...
4
The "arithmetic shift right" operation is similar to a normal (logical) shift right, except the most significant (i.e. shifted-in) bits are filled with the sign bit rather than 0. Unfortu...
Inly asked 17/6, 2023 at 6:49
3
Solved
For most operators that might overflow, Rust provides a checked version. For example, to test if an addition overflows one could use checked_add:
match 255u8.checked_add(1) {
Some(_) => println...
Norway asked 22/8, 2020 at 15:3
1
How does one shift a long array n positions to the right or left e.g. do a >>> n or << n on this array
long[] values = new long[]{
0b101101001111111100110011100000010011001110110111...
Rhinelandpalatinate asked 8/3, 2023 at 21:13
4
I remember in an assembly class, we learned the m68k processor, and there were 3 kinds of shifts you could do. Linear shift, circular shift, and circular shift with extend.
The last one, circular ...
Kwang asked 3/12, 2017 at 18:42
1
Solved
I get this error when attempting to do >> or >>= on a BigInt:
no implementation for `BigInt >> BigInt
using the num_bigint::BigInt library
Edit: More Context:
I am rewriting this ...
2
Solved
Consider the following listing:
#include <type_traits>
#include <cstdint>
static_assert(std::is_same_v<decltype(31), int32_t>);
static_assert(std::is_same_v<decltype(31u), uin...
Delectable asked 5/1, 2023 at 13:49
3
Solved
I have a byte variable:
byte varB = (byte) -1; // binary view: 1111 1111
I want to see the two left-most bits and do an unsigned right shift of 6 digits:
varB = (byte) (varB >>> 6);
...
Nicknickel asked 16/4, 2015 at 17:49
1
What is the most optimal way to convert a decimal number into its binary form ,i.e with the best time complexity?
Normally to convert a decimal number into binary,we keep on dividing the number by...
Prostatectomy asked 2/10, 2013 at 11:31
9
Solved
Apple sometimes uses the Bitwise-Shift operator in their enum definitions. For example, in the CGDirectDisplay.h file which is part of Core Graphics:
enum {
kCGDisplayBeginConfigurationFlag = (1 ...
Collation asked 22/10, 2010 at 18:44
3
Solved
I encountered a strange problem, but to make it clear see the code first:
#include <stdio.h>
#include <stdint.h>
int main() {
uint8_t a = 0b1000'0000; // -> one leftmost bit
uint8...
Elka asked 4/11, 2022 at 12:9
1 Next >
© 2022 - 2024 — McMap. All rights reserved.