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

Java: Shift all character-codes inside a String by a constant value

This works: for (char c : sourceString.toCharArray()) destString += (char) (c + shiftValue); System.out.println(destString); Is there a better/faster (optimized) way?
Mir-Ismaili
  • 13,974
  • 8
  • 82
  • 100
7
votes
1 answer

What is the use of (+) bareword with shift operator?

I'm learning the intermediate perl.In that now I'm studying about the object references for class.In that they gave one package { package Barn; sub new { bless [], shift } sub add { push @{ +shift }, shift } sub contents { @{…
7
votes
3 answers

how to get the shifted index value of a dataframe in Pandas?

Consider the simple example below: date = pd.date_range('1/1/2011', periods=5, freq='H') df = pd.DataFrame({'cat' : ['A', 'A', 'A', 'B', 'B']}, index = date) df Out[278]: cat 2011-01-01 00:00:00 …
ℕʘʘḆḽḘ
  • 18,566
  • 34
  • 128
  • 235
7
votes
1 answer

Ctrl or Shift effects on the `onclick` event of an anchor tag in each browser

I recently discovered that different browsers handle the onclick event differently when the Control or Shift keys are pressed. They diverge similarly on behavior for for following links by clicking the middle mouse button. With the following…
Erik
  • 559
  • 1
  • 8
  • 17
7
votes
2 answers

Why does right shifting -1 always gives -1 in PHP?

I am trying to figure out why if I shift the negative integer -1 I always get -1, e.g.: echo -1 >> 64; // -1 echo -1 >> 5; // -1 echo -1 >> 43; // -1 echo -1 >> 1; // -1 Whatever second operand of the right shift is given, -1 remains -1... I do…
tonix
  • 6,671
  • 13
  • 75
  • 136
7
votes
2 answers

Can I shift the objects in a NSMutableArray without creating a temporary array?

I thought I had it with, void shiftArray(NSMutableArray *mutableArray, NSUInteger shift) { for (NSUInteger i = 0; i < [mutableArray count]; i++) { NSUInteger newIndex = (i + shift) % [mutableArray count]; [mutableArray…
willc2
  • 38,991
  • 25
  • 88
  • 99
7
votes
1 answer

Javascript: Why does this benchmark show array.shift() to be so much faster than array[i] at reading off values from an array?

A quick question only. I created the benchmark (link below), and for me at least (running chrome 18.0.1025), reading values from the front of an array using array.shift() each time seems remarkably faster than reading the values using a while/for…
jsdw
  • 5,424
  • 4
  • 25
  • 29
7
votes
3 answers

Is the shiftkey held down in JavaScript

I have written a JS function that only allow numbers to be entered. A copy of that function is below: function NumbersOnly(e) { var evt = e || window.event; if (evt) { var keyCode = evt.charCode || evt.keyCode; //Allow tab,…
Sun
  • 4,458
  • 14
  • 66
  • 108
6
votes
5 answers

Detect shift key on application startup in C#/Windows Forms

Is there a way to get a standard Windows Forms application to detect if the Shift key is being held down on application startup - without using Windows hooks? I ideally would like the workflow to change from normal if the shift key is held down when…
Grant
  • 11,138
  • 32
  • 94
  • 140
6
votes
4 answers

ASCII character from VK_Code

I have a small WIN32 C-Application in which i work with the KBDLLHOOKSTRUCT structure. This structure contains the VK-Code for a pressed key. I try to convert this to an ASCII-Character. For this i use the Function MapVirtualKey, which works…
Kevin Meier
  • 2,339
  • 3
  • 25
  • 52
6
votes
5 answers

Perl shift operator simple question

What's the purpose of the following two lines of perl?? my $host = shift || 'localhost'; my $port = shift || 200; That should return localhost and port 10. What is the shift keyword??
Marco A.
  • 43,032
  • 26
  • 132
  • 246
6
votes
2 answers

Bitwise shift *by* a negative number to reverse the bits in a number

Is it valid to perform a bitwise shift by a negative amount? For example, if I have the following code: #include uint32_t reverse_bits (uint32_t n) { uint32_t result = 0; for (int i = 0; i < 32; i++) { uint32_t…
rsethc
  • 2,485
  • 2
  • 17
  • 27
6
votes
2 answers

slice shift like function in go lang

how array shift function works with slices? package main import "fmt" func main() { s := []int{2, 3, 5, 7, 11, 13} for k, v := range s { x, a := s[0], s[1:] // get and remove the 0 index element from slice fmt.Println(a)…
user7014993
6
votes
2 answers

JavaScript - for Loop vs. Array shift

I have two functions, they do look alike but what I don't really understand is when inside the for-loop, since the input is an array, why doesn't the array need any index to call the first array? I have an array of... var puzzlers = [ function(a) {…
Dora
  • 6,776
  • 14
  • 51
  • 99
6
votes
1 answer

iPhone keyboard shift key disabled

I have a UITextField where the keyboard that pops up has its Shift key disabled. The keyboard type is set to UIKeyboardTypeNamePhonePad, which seems like it should allow capitals. If I change the keyboard type to "default" but leave other…
Tom Harrington
  • 69,312
  • 10
  • 146
  • 170