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

Shell shift procedure - What is this?

In shell we have the command shift, but i saw on some example its giving shift 3 Why there is a number after shift ? and what its about ? what it does ? Example: echo “arg1= $1 arg2=$2 arg3=$3” shift echo “arg1= $1 arg2=$2 arg3=$3” shift echo…
user1253622
  • 227
  • 1
  • 4
  • 8
18
votes
3 answers

How do you get multiple arguments in Perl functions?

In my code, I'm been using the fairly primitive method of extraction parameters from a function call as follows: sub addSix ($$$$$$) { my ($a, $b, $c, $d, $e, $f) = (shift, shift, shift, shift, shift, shift); return $a + $b + $c + $d + $e +…
paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953
18
votes
3 answers

JavaScript can't capture "SHIFT+TAB" combination

For whatever reason I can't capture "SHIFT+TAB" combination. I am using the latest jQuery. Same result if I use other ajax/javascript, etc. Here is a simple example that should work as I currently understand it... event.which or event.KeyCode are…
Bohemian
  • 181
  • 1
  • 1
  • 3
17
votes
7 answers

in perl, is it bad practice to call multiple subroutines with default arguments?

I am learning perl and understand that it is a common and accepted practice to unpack subroutine arguments using shift. I also understand that it is common and acceptable practice to omit function arguments to use the default @_ array. Considering…
Mythoranium
  • 195
  • 1
  • 7
15
votes
6 answers

Bitshifting in Java

I'm trying to understand how bit shift works. Can someone please explain the meaning of this line: while ((n&1)==0) n >>= 1; where n is an integer and give me an example of a n when the shift is executed.
Alexander
  • 159
  • 1
  • 1
  • 3
15
votes
10 answers

Can anyone explain why '>>2' shift means 'divided by 4' in C codes?

I know and understand the result. For example:
7 (decimal) = 00000111 (binary)
and 7 >> 2 = 00000001 (binary)
00000001 (binary) is same as 7 / 4 = 1
So 7 >> 2 = 7 / 4

But I'd like to know how this logic was created.…
user573566
  • 509
  • 2
  • 6
  • 9
14
votes
1 answer

Python Unsigned Right Shift

Possible Duplicate: How to get the logical right binary shift in python How do I perform an unsigned right shift in python? I.E. The java equivalent is this: x >>> y or x >>>= y
Micah
  • 149
  • 1
  • 1
  • 3
14
votes
4 answers

In C Left shift (char) 0xFF by 8 and cast it to int

On left shift of (char) 0xff by 8 and casting it to int we get -256 or 0xffffff00. Can somebody explain why this should happen? #include int main (void) { char c = 0xff; printf("%d %x\n", (int)(c<<8),(int)(c<<8)); return…
Geos
  • 1,471
  • 4
  • 14
  • 16
13
votes
1 answer

How to indent/shift a line of code or a block of code in IntelliJ IDEA

I can shift a line of code or a block of code in Eclipse by the following way: Focus a line or select a block of source code Source menu -> Click "Shift Left" or "Shift Right" How to do the same thing in IntelliJ IDEA?
Ripon Al Wasim
  • 36,924
  • 42
  • 155
  • 176
13
votes
11 answers

Shifting a String in C#

static void Main(string[] args) { string s = "ABCDEFGH"; string newS = ShiftString(s); Console.WriteLine(newS); } public static string ShiftString(string t) { char[] c = t.ToCharArray(); char save = c[0]; for…
user2104751
  • 149
  • 1
  • 1
  • 6
11
votes
2 answers

How to shift several rows in a pandas DataFrame?

I have the following pandas Dataframe: import pandas as pd data = {'one' : pd.Series([1.], index=['a']), 'two' : pd.Series([1., 2.], index=['a', 'b']), 'three' : pd.Series([1., 2., 3., 4.], index=['a', 'b', 'c', 'd'])} df = pd.DataFrame(data) df =…
ShanZhengYang
  • 16,511
  • 49
  • 132
  • 234
11
votes
3 answers

What is the value of number left shift by -1

What is the result of number when it is left shifted by -1 in C programming using the left shift operator? e.g.: 23 << -1
Mithun Arunan
  • 922
  • 9
  • 18
11
votes
2 answers

How to determine if the SHIFT or CTRL key was pressed when launching the application

I need to be able to determine if the SHIFT or CTRL keys were pressed when the application is launched How can I do this for a Windows Forms Application?
slayernoah
  • 4,382
  • 11
  • 42
  • 73
10
votes
3 answers

Change elements positions in an array and shift elements in between

I would like to pick an element in an array, move it to another index, and then "shift/rotate" the "in-between" elements by 1. Imagine a drag and drop functionality, if the index from is less than index to, then I would like to shift to be to the…
Khalil Khalaf
  • 9,259
  • 11
  • 62
  • 104
10
votes
2 answers

Something wrong with javascript unsigned shift operator on iPad?

I accidentally ran into what appears to be a very strange bug in Safari's javascript engine on iPad. The unsigned shift operator >>> is supposed to bitwise right-shift a number. I experienced some errors in a script that worked fine on other…
Rogier
  • 153
  • 5
1
2
3
70 71