Questions tagged [shift]

Questions related to the usage of the right and/or left shift key on the keyboard. For questions regarding bitwise shift operations use [bit-shift]

Questions related to the usage of the right and/or left Shift key on the keyboard. For questions regarding bitwise shift operations use

1054 questions
-3
votes
1 answer

array shift and sum

Help with solving this problem, or give me the name of the algorithm for this: A one-dimensional array of length N is given randomly filled with numbers, all of which are powers of two. Two operations can be performed on the array: left and right…
-3
votes
1 answer

How to decrypt a shifted message with XOR?

I have a message m that I encrypt by the code c = m xor [m<<6] xor [m<<10] (m<>6] xor [c>>10]…
BOSAnonym
  • 9
  • 1
-3
votes
3 answers

Optimizing XOR of `char` with the highest byte of `int`

Let we have int i and char c. When use i ^= c the compiler will XOR c with the lowest byte of i, and will translate the code to the single processor instruction. When we need to XOR c with highest byte of i we can do something like this: i ^= c <<…
NoSkill
  • 718
  • 5
  • 15
-3
votes
1 answer

Bitwise logical operator and shift operator

This code is an example from a book that the problem require to change decimal to binary number using bitwise AND operator and the shift operator. I cannot understand the code although had tried to understand this code using debug compiler. Suppose…
fiksx
  • 176
  • 1
  • 15
-3
votes
3 answers

Shift the index of sparse matrix without loop in matlab

I really afraid to ask about this, but I don't know any way to shift the index of an sparse matrix without loop Sparse matrix is something like this a = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 …
Morteza R
  • 7
  • 4
-3
votes
1 answer

Use java to perform binary shifts

I have to take a binary data in java and perform shifts on it. For e.g. 11110000 when I right shift it by 2 , i.e. 11110000>>00111100 The problem is that, I don't know how to store such a data in Java, as the byte type converts it to decimal format.…
chettyharish
  • 1,704
  • 7
  • 27
  • 41
-4
votes
1 answer

Xor and Cyclic shift

Suppose we have this equation c = m ⊕ (m << 6) ⊕ (m << 10) where ⊕ stands for XOR and << for cyclic shift to the left. How can this be written as m in terms of c? What operations must be used? I tried xoring both sides with c << 6 but didnt result…
-4
votes
1 answer

I want to understand the working of this Java program in detail? Why are we doing it and how are we taking such values to solve this?

class shift_right { public static void main(String args[]) { char hex[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; byte b = (byte) 0xf1; System.out.println("b = 0x" + hex[(b >> 4) & 0x0f] +…
-4
votes
1 answer

shift by left an array withh given value

#include #include #include using namespace std; void shiftLeft (char myarray[], int size, int shiftBy) { if(shiftBy > size){ shiftBy = shiftBy - size; } if(size == 1){ //do nothing } …
shiv zuh
  • 125
  • 11
-4
votes
2 answers

Java: Replacing the values in an array and shifting the elements in an array

So I've been tasked with completing this program for my AP Computer Science class: Write the code that takes an array of doubles and moves all the values greater than the average to fill the array to the left. Any values less than the average…
Leslie A.
  • 3
  • 1
  • 2
-4
votes
3 answers

shift each letter of words by value

I am trying to take a value from user and read a list of words from a Passwords.txt file, and shift each letter to right by value •def shift(): value=eval(input("Please enter the value here.")) file = open("Passwords.txt","w") with open…
user2924427
-4
votes
2 answers

How do I circular shift some characters/bits?

I need to circular shift some characters/bit using Perl For example, with the following input (reversing character strings): 1010 1110 hello I need to obtain: 0101 0111 olleh How do I achieve this using Perl?
user1539348
  • 513
  • 1
  • 7
  • 20
-5
votes
1 answer

c# bit shift task with integers

theres an exam task and im wondering how to solve that properly. Task: We have to write the output of this code as the solution. int iq = -99887766; string pout = ""; int mask = 1 << 31; for (int n = 1; n <= 32; n++) …
Julian Herbold
  • 537
  • 9
  • 20
-5
votes
2 answers

Shifting arrays without using loops

I have been asked to equate two strings using recursion. Absolutely no loops are allowed. My idea is to check element by element, shrinking the string over time, but I don't know how to implement it. I want to delete the elements of the array once I…
bgenchel
  • 3,739
  • 4
  • 19
  • 28
-6
votes
1 answer

Explanation of shift operationals use in condition

I have a c code given to me to fill for my thesis. Can you please explain what the following segment does, because i'm very buffled with it. int i; _int8 codeword[64800]; //loop running through codeword if (codeword[i << 1] << 1 | codeword[i << 1 |…
1 2 3
70
71