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
5
votes
3 answers

Bitshifting in C++ producing the wrong answer

I tried running the following code code: char c = (2 << 7) >> 7 which should return 0 because 2 has this binary representation as a char: 0 0 0 0 0 0 1 0 After 7 shifts left, we get 0 0 0 0 0 0 0 0 Then, after seven shifts right, we get 0 0 0 0…
MyNick
  • 536
  • 1
  • 9
  • 25
5
votes
4 answers

How to remove nth element from command arguments in bash

How to I remove the nth element from an argument list in bash? Shift only appears to remove the first n, but I want to keep some of the first. I want something like: #!/bin/sh set -x echo $@ shift (from position 2) echo $@ So when I call it - it…
ManInMoon
  • 6,795
  • 15
  • 70
  • 133
5
votes
1 answer

Array.first Vs Array.shift in Ruby

I'm essentially going through an exercise for rewriting a basic form of the inject method from the Enumerable module and my solution was not doing anything as I was using #first: def injecting(*acc, &block) acc = acc.empty? ? self.first :…
Maikon
  • 1,382
  • 16
  • 16
5
votes
2 answers

C - Using bit-shift operators for base conversion

I'm trying to convert some data from hex to base64 in C, I found an algorithm online but I would really like to know how it works rather than just implenting it and firing it off. If someone could please explain how the following is working I would…
bry6891
  • 81
  • 2
  • 7
5
votes
1 answer

Bitwise right shift >> in Objective-C

I have a variable (unsigned int) part_1. If I do this: NSLog(@"%u %08x", part_1, part_1); (print unsigned value, and hex value) it outputs: 2063597568 7b000000 (only first two will have values). I want to convert this to 0000007b So i've tried…
user2955517
  • 273
  • 3
  • 5
5
votes
2 answers

Shift + Click to Select a Range of Checkboxes

I have large tables being generated and each row has a checkbox, class "chcktbl". In the table header, there is a Select All checkbox, class "chckHead". The select/deselect all function works fine, as does the count of selected charts I have…
user2690652
  • 73
  • 2
  • 4
5
votes
6 answers

Can a bool variable store more than 0x01?

#include #include using namespace std; int main() { bool a = 0x03; bitset<8> x(a); cout<>1; bitset<8> y(a); cout<
user2261693
  • 405
  • 3
  • 7
  • 11
5
votes
2 answers

theEvent charactersIgnoringModifiers - Get characters without modifiers

Im trying to implement a keyboard class in my game that has two modes. The game mode takes input that uses lowercase, unmodified keys (unmodified meaning if I type a '0' with the shift it still returns '0' instead of ')'). I have tracked it down as…
Chase Walden
  • 1,252
  • 1
  • 14
  • 31
5
votes
2 answers

Shifting 64 bit value left by 64 bits in C++ giving weird results

Possible Duplicate: 64bit shift problem I'm using Visual Studio 2012 on Windows 8 64-bit, targeting x64 in debug mode, using an AMD Phenom II. So Basically... uint64_t Foo = 0xFFFFFFFFFFFFFFFF << 64;//Foo is now 0x0000000000000000 uint64_t Derp =…
retep998
  • 888
  • 1
  • 9
  • 14
5
votes
0 answers

Disable Shift + right-click in firefox while using an applet

I am working on a site that uses a fairly advanced applet that binds the mouse and keyboard to it so nothing is supposed to affect the browser until you hit esc key. to get back to the site. It is all working fine but: if i hit shift + right-click,…
4
votes
0 answers

Programming "enter" and "shift-enter" for EditText using a soft keyboard

I am developing an Android application that makes use of EditText (Multiline). The devices I am testing it on lack hard keyboards, so as a result I (obviously) use the soft keyboard. When I touch/click on the EditText the soft keyboard appears. The…
4
votes
4 answers

How shift data in all columns in R data frame?

I have the following R data.frame df <- data.table( id = c(1, 2, 3), x = c(1, NA, NA), y = c(NA, 2, NA), z = c(NA, NA, 3)) And, I'd like to shift all data up from the "y" and all next columns without changing values order. The number of…
Andrii
  • 2,843
  • 27
  • 33
4
votes
0 answers

Shifting long vectors between AVX registers (on pre AVX512VL CPUs)

I in the process of making some 2D/planar image data resampler and current highest performance approach of 2D convolution need to perform shift of long float32 vector between AVX (ymm or zmm) registers at fixed number of float32 (4 byte) values. The…
DTL2020
  • 71
  • 3
4
votes
3 answers

Shorter way to create new column in groupby() based on previous n rows

I have the following code that for a sorted Pandas data frame, groups by one column, and creates two new columns: one according to the previous 4 rows and current row in the group, and one based on the future row in the group. data_test =…
4
votes
1 answer

How to use the BitShift operator in Pytorch?

Does anyone has an example of how to use the BitShift operator in Pytorch?