shift

Shift Left Logical <<

How exactly do I do this in C/C++? Let's say I want to shift int i twice to the left and store the value in f. f = i << 2 ? I don't need this for a program or anything, I'm just interested in how it works. Thanks. ...

Left Shift Overflow on 68k/x86?

I heard that the Motorola 68000 and Intel x86 architectures handle overflow from left shifting differently. Specifically the 68k LSL vs. the Intel SAL/SHL assembly instructions. Does anyone know the specifics of this? Do they set different flags, or set them differently? I tried to look this up in the reference manuals, but I don't see ...

Perl - Why does shift lose its value after being used?

This code works - It takes an array of full txt file paths and strips them so that when $exam_nums[$x] is called, it returns the file name for (0..$#exam_nums) { $exam_nums[$_] =~ s/\.txt$//; #remove extension $exam_nums[$_] =~ s/$dir//g; #remove path } When I try to do this for a single variable, it doesn't work. I'm calling a sub...

C unsigned int array and bit shifts

If i have an array of short unsigned ints. Would shifting array[k+1] left by 8 bits, put 8 bits into the lower half of array[k+1]? Or do they simply drop off as they have gone outside of the allocated space for the element? ...

How find a variable value in MOD expression?

9 = 2^X mod 11 What is X and how do you find X? Its related to finding the plain text in RSA algorithm and I'm writing a C program for it. ...

shifting right / what I am doing wrong?

Does not work as expected becuase it does not set the MSB bit correct. I am using metrowerks compiler. //shifting right 5 characters char * buffer; buffer=global_buffer; for(i=0;i<5;i++) //shift right for 1; { buffer[17-i]=(buffer[17-i]>>1)|(buffer[17-i-1]<<7); } EDIT input buffer (just before for loop) 0x00,0x00,0x00,0x00,0x00,0x...

Efficient way to shift a list in python

What is the most efficient way to shift a list in python? Right now I have something like this: >>> shift = lambda l, n: l[n:]+l[:n] >>> l = [1,2,3] >>> shift(l,1) [2, 3, 1] >>> shift(l,2) [3, 1, 2] >>> shift(l,0) [1, 2, 3] Is there a better way? ...

Is there a way to allow paste from the clipboard using Shift-Insert on top of CTRL-V?

I know that you can use the context menu using a right-mouse-click in a control to choose to cut, copy, paste, etc. I've also noticed that you can use the windows keyboard shortcuts CTRL-C for Copy and CTRL-V for Paste. Windows supports native CTRL-Insert (for copy) and SHIFT-Insert (for paste). However, within Flex, it seems these do...

Shift + Click of Linkbutton in Firefox opens new window instead of firing OnClick

I used C# to build a gallery of photos. Users can hold down shift and click to select multiple photos at once. I used the System.Windows.Forms.Control.ModifierKeys property to determine whether shift is being pressed in the OnClick event of a link button, but find that it only works in IE. In Firefox, Shift + Click opens a new window and...

C# quickest way to shift array

How can i quickly shift all the items in an array one to the left, padding the end with null? [0,1,2,3,4,5,6] would become [0,2,3,4,5,6,null] Edit: I said quickly but I guess I meant efficiently. I need to do this without creating a List or some other data structure. This is something I need to do several hundred thousand times in as s...

ActionScript shiftKey Not Working In Full Screen Mode?

i've drawn an ellipse sprite and added it to the display list of a container, which is added to the display list of the stage. to move the sprites with the keyboard arrows, it appears that my shiftModifier:Number variable is not working when the stage's display state is set to full screen. shiftModifier works as it should when the stag...

Using RotateFlip of bitmap class with pixelformat 1bppIndexed, image shifts 8 pixels left.

//I create a bitmap to hold a 1 bit per pixel image: format = PixelFormat.Format1bppIndexed; bitmap = new Bitmap(width, height, format); //Then I fill the bitmap programatically. ... //I check pixels left and right using bitmap.GetPixel(x,y)... //Then I mirror the image bitmap.RotateFlip(RotateFlipType.RotateNoneFlipX); //When I check...

Circular Shifts on Strings in Bash

I have a homework assignment where I need to take input from a file and continuously remove the first word in a line and append it to the end of the line until all combinations have been done. I really don't know where to begin and would be thankful for any sort of direction. The part that has me confused is that this is suppose to be pe...

Bitwise Shifting in C

I've recently decided to undertake an SMS project for sending and receiving SMS though a mobile. The data is sent in PDU format - I am required to change ASCII characters to 7 bit GSM alphabet characters. To do this I've come across several examples, such as http://www.dreamfabric.com/sms/hello.html This example shows Rightmost bits o...

Disabling shift-click in a Flex 4 AdvancedDataGrid with allowMulitpleSelect enabled.

I have an AdvancedDataGrid for which I would like to allow multiple selection. Do to several constraints, I want to disallow selecting items that are next to each other (Basically, you can't select multiple items with the same parent and parents are handled differently from children). My preference would be to stop event propagation when...

Pygame program that can get keyboard input with caps

I have a Pygame program that needs text input. The way it does this is to get keyboard input and when a key is pressed it renders that key so it is added to the screen. Essentially it acts like a text field. The problem is, when you hold shift it doesn't do anything. I relize this is because the program ignores shift input and instead wr...

SQL timetable for employee

Hi guys, i need to create an employee shift database. so i have 3 tables so far, employee, employee_shift, and shift im suppose to calculate how many shifts an employee has done at the end of the month, my question means, because a month has 30 days some have 28 and 31 days. this means i need to create in the shift table 31 different ...

ctrl+click or shift+click not always firing the onclick event

Hi, I recently discovered that different browsers handle the onclick event differently when the control of shift key is pressed. Same thing for following links with the middle mouse button. <a href="http://www.example.com/" onclick="alert('onclick');">go to example.com</a> Onclick browser support table Mouse Keyboard C...

How to solve a shift/reduce conflict?

Hi, I'm using CUP to create a parser that I need for my thesis. I have a shift/reduce conflict in my grammar. I have this production rule: command ::= IDENTIFIER | IDENTIFIER LPAREN parlist RPAREN; and I have this warning: Warning : *** Shift/Reduce conflict found in state #3 between command ::= IDENTIFIER (*) and command :...

Perl pack/unpack/shift

I've been having this problem in Perl for a few days now, and after scouring countless man pages, perldocs and googling too many search terms, hopefully someone here can help me out. I am given two strings which represent hex values, i.e. "FFFF", not the Perl hex number 0xFFFF. Given two of these strings, I wish to convert them to bina...