Click here to Skip to main content
15,881,281 members
Everything / Shift

Shift

shift

Great Reads

by ASP.NET Community
Visual Studio keyboard bindings:201020082005 Followings are some useful shortcuts for coders:Copy a single line - CTRL+C [Move the insertion
by DaveAuld
A beginners' introduction to using shift registers with the Arduino
by honey the codewitch
Easily shift bits in memory of arbitrary length, declare integer sizes programmatically, endian conversion, and more

Latest Articles

by honey the codewitch
Easily shift bits in memory of arbitrary length, declare integer sizes programmatically, endian conversion, and more
by ASP.NET Community
Visual Studio keyboard bindings:201020082005 Followings are some useful shortcuts for coders:Copy a single line - CTRL+C [Move the insertion
by DaveAuld
A beginners' introduction to using shift registers with the Arduino

All Articles

Sort by Score

Shift 

12 May 2011 by Yusuf
[In support of @OriginalGriff Answer:]using memmove you will gain performance but at an expense of readability and a chance to shoot yourself in the foot. Remember you are dealing with raw mem locations and slight shift can have.... you know what I mean.If you are dealing with small set...
4 Jun 2021 by CPallini
The function returns the value of the loc bit of the integer variable num. Note you could rewrite it this way int float_bit_return(int num, int loc) { return ((num >> loc) & 1); } (the inner braces are not needed due to C operator...
19 Jun 2017 by CPallini
If you need to insert blanks somewhere in the string (like your example suggests) then the string::insert method ( see string::insert - C++ Reference[^]) is your friend: #include #include using namespace std; int main() { string s = "hello"; s.insert(1, 1, ' '); ...
15 Apr 2020 by KarstenK
"Yes - You can!" if you array isnt constant declared. (a) first you must extract and save one element, (b) than you can assign the second value to the first one (c) and last you assign the first (and saved) value to the second element. int...
16 Apr 2020 by OriginalGriff
So declare and fill array A and B. Then declare array result as 2D, X by Z elements. Then you need two nested loops: One to process each "row" in B, and one to porcess each element of A. In the inner loop, copy each element of A to the output...
17 May 2011 by John R. Shaw
Just thought I would give you a number of solutions that you can play with.Interesting - no one noted that even as pseudo code that 'for' loop example is invalid.#include // if C++ copy_backward() function template is used#include // if C memmove function is...
17 May 2011 by xtayaitak
int newNum;for (int i=19;i>0;i--) { a[i]=a[i-1]; } a[0]=nuwNum;
12 May 2011 by Member 7796364
I am trying to figure out how to shift an array.Say I have an array int data=[20];and wanted to shift right so data [19] is gone and 18 moves to 19. Then I would fill [0] with a new number.Would I have to use Something likefor (i=19, i
11 Oct 2013 by ASP.NET Community
Visual Studio keyboard bindings:201020082005 Followings are some useful shortcuts for coders:Copy a single line - CTRL+C [Move the insertion
9 Jun 2014 by Florian Trück
Hi,I have this snippet where the .net compiler outputs the above mentioned warning.private static int BitwiseRotate(int x, int c){ var num = (uint) x; return (int) (x > 32 - c);}If possible I would correct this to get no warning. I do not want to place any...
9 Jun 2014 by Kornfeld Eliyahu Peter
The problem is with the types of num and c...c is a int (signed) where num is uint (unsigned) so num >> 32- c will force the compiler to extend num to int (unsigned) and that the reason for the warning...
10 Jun 2014 by phil.o
What is the benefit of the use of the num variable?Your code could be shortened to:private static int BitwiseRotate(int x, int c) { return (x > (32 - c));}No need to cross cast between int and uint.I think the problem you had in the first place was that you...
19 Feb 2015 by bh7578
Hi All,I have implemented a editor base on richtextbox control, I want to use the combination keys Shift+2,Shift+4,Shift+6,Shift+8 to do some special things, but by default these combination keys is used as the direction keys, that Down,Left, Right, Up, my question is How can I disable the...
19 Jun 2017 by Nilesh Sinha
how can i shift the indexes in a string,suppose i have declared a string i.e String str; cin>>str; //now,i want to modify the same string as i want to shift the elements in the // string by a particular no. //for example str="hello"; // say shift 2 palaces...
16 Apr 2020 by Member 14802198
How can I change the location of members of an array based on members of another array? I am given an array A with length X, and another array B containing Z pairs of elements from A. The program should output a Z by X array, where the n th row...
10 Jan 2011 by DaveAuld
A beginners' introduction to using shift registers with the Arduino
18 May 2021 by honey the codewitch
Easily shift bits in memory of arbitrary length, declare integer sizes programmatically, endian conversion, and more
12 May 2011 by OriginalGriff
You can't easily do it with memmove, because you want to shift it all right one place: memmove (data + 1,data,19);will copy the first byte through the whole of "data"!I would stick with the for loop - it's pretty obvious and it saves creating an intermediate copy of the data, which you would...
18 Jun 2017 by Jochen Arndt
Your question is unclear. Your example "he llo" is not shifted but has a space inserted. A shift operation would result in something like "ello" (shift left by one) or " hello" (shift right by one; may be also " hell" depending on the shift definition). Check the methods provided by your...
18 Jun 2017 by OriginalGriff
It's going to depend on what environment your application is to run in: a CLR app could use one String class which has Substring functions, while a native app might have to use a different string class which supports substr instead. But basically the operation will be along the lines of:...
10 Jun 2014 by future2015
In C#, shift operators are not logical and if operand is negative, shifts 1.private static int BitwiseRotate(int x, int c) // rotate left{ var num = (uint) x; return (int) ((num > (32 - c));}
23 Jun 2014 by Florian Trück
What about this one?private static int BitwiseRotate(int value, int count){ var val = (uint)value; return (int)((val > (32 - count)));}It generates no compiler warnings.I found it on the net.
4 Jun 2021 by Rahul Dicholkar
int float_bit_return(int num, int loc) { return (num & 1