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
6
votes
4 answers

What's the benefit of shifting @_ for argument passing in Perl?

sub foo { $arg1 = shift @_; $arg2 = shift @_; # ... } What's the benefit of this idiom? I see only disadvantages compared to explicitly working with $_[0], $_[1], ... The array has to be shifted, which is time consuming. It is destroyed, so that…
ubuplex
  • 189
  • 1
  • 5
6
votes
3 answers

How to get the bit removed from the bitwise right shift in c#

I have a int number And I have to shift it to the right a couple of times. x = 27 = 11011 x>>1= 13 = 1101 x>>2= 6 = 110 x>>3= 3 = 11 I would like to get the value bit value that has been removed. I would have to get: 1, 1, 0 How can I get the…
user853710
  • 1,715
  • 1
  • 13
  • 27
6
votes
2 answers

Shifting 2D array Verilog

I dont know what doesnt work on the following code, but it wont synthesize: reg [7:0] FIFO [0:8]; always@(posedge clk) begin if(wr & !rd & !full) begin FIFO[0:8] <= {data_in, FIFO[1:8]}; end end I tried to index the FIFO other ways…
zsidanyi
  • 105
  • 1
  • 2
  • 6
6
votes
1 answer

How to correct / shift subtitle time in SRT (SubRip) files?

How to correct/shift subtitle time forward and backward? Subtitle time format looks like this: 00:00:52,656 --> 00:00:56,326 If subtitle and audio aren't synchronized, for example, subtitle shows up before voice/audio, then all times of subtitle…
Srdjan Vukmirica
  • 743
  • 2
  • 8
  • 22
5
votes
3 answers

Pandas Shift Date Time Columns Back One Hour

I have data in a DF (df1) that starts and ends like this below and I'm trying to shift the "0" and "1" columns below so that the date and time is moved back one hour so that the date and time start at hour == 0 not hour == 1. data starts (df1) - …
user2100039
  • 1,280
  • 2
  • 16
  • 31
5
votes
2 answers

Shift + Enter vs Enter in console

I am trying to catch all characters that I input via my stdin stream except EOF. I want to input a multi-line text: each line with \n at the end. int getline(char s[]) { printf("Call-getline()\n"); int c; int idx=0; …
Cătălina Sîrbu
  • 1,253
  • 9
  • 30
5
votes
1 answer

In C, for example, why is second operand of shift allowed to be signed?

Note: This question is all about the signedness of the second operand of bit shift operators << and >>. Not at all about the first operand. CERT INT34-C, in part: Do not shift a negative number of bits ... Not that it needed justification, but they…
talkaboutquality
  • 1,312
  • 2
  • 16
  • 34
5
votes
1 answer

detect/get notification if shift key (modifier-key) pressed in uitextview

I'm trying to figure out if there is any way in which we can detect if shift key is pressed or if any notification is sent when shift key is pressed in UIKeyboard - (BOOL) textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range…
dips
  • 227
  • 2
  • 12
5
votes
1 answer

Why is shift faster than index access in this JavaScript example?

// Shifting the array and accessing 0 let sum = 0; while(matrix.length > 0) { sum += matrix[0][0]; matrix.shift(); } // direct access let sum = 0; for (let i = 0; i < matrix.length; i++) { sum +=…
ran
  • 59
  • 3
5
votes
3 answers

Compute winning streak with pandas

I thought I knew how to do this but I'm pulling my hair out over it. I'm trying to use a function to create a new column. The function looks at the value of the win column in the current row and needs to compare it to the previous number in the win…
mintgreenstrat
  • 121
  • 1
  • 8
5
votes
4 answers

Is there an equivalent to head/tail for Foldable functors in general?

I would like to express the following Haskell code, using only functor algebra (i.e. - not relying on any specific container type, such as List): ys = zipWith (+) (head xs : repeat 0) (tail xs ++ [y]) It seems to me that there…
dbanas
  • 1,707
  • 14
  • 24
5
votes
3 answers

Pandas Check last N Rows for values, new column based on results

I have a DataFrame, Df2. I'm trying to check each of the last 10 rows for the column Lead_Lag below - if there's any value besides null in any of those rows, then I want a new column Position to equal 'Y': def run_HG_AUDUSD_15M_Aggregate(): Df1…
Cole Starbuck
  • 603
  • 3
  • 11
  • 21
5
votes
2 answers

Pandas - Identify Last Row by Date

I'm trying to accomplish two things in my Pandas dataframe: Create new column Last Row ('Yes' or 'No') based on new DateCompleted Capture the next transaction on the current row, unless it's a new DateCompleted (in which case mark as…
Walt Reed
  • 1,336
  • 2
  • 17
  • 26
5
votes
6 answers

C: clever way to "shift" a matrix?

I have an integer matrix that should act like a buffer: x = {{0, 0, 0, 0, 0}, {1, 1, 1, 1, 1}, {2, 2, 2, 2, 2}}; Now if I add a new row {3, 3, 3, 3, 3}, the new matrix should look like: x = {{1, 1, 1, 1, 1}, {2, 2, 2, 2, 2}, {3, 3, 3, 3, 3}}; Is…
fi_34k7
  • 53
  • 3
5
votes
2 answers

Shift time series with missing dates in Pandas

I have a times series with some missing entries, that looks like this: date value --------------- 2000 5 2001 10 2003 8 2004 72 2005 12 2007 13 I would like to do create a column for the "previous_value". But I…
user3591836
  • 953
  • 2
  • 16
  • 29