I know there is similar questions to my question, however, they aren't the same. All of them are just normal shifts, circular shifts etc. not having a through Carry flag.
I am trying to implement a method that does a right rotate through carry flag, carry flag being 1, current code:
public static int RotateRight(int value, int count = 2)
{
uint val = (uint)value;
return (int)((val >> count) | (val << (32 - count)));
}
However, this works only as normal shift, an input of 16 returns 4. How would one create a carry flag?
Before an admin points to this question C# bitwise rotate left and rotate right this does a normal rotate without a through carry flag.
Another example of this:
10 >> 2 with carry through flag of 1
1 00010000
Rotate with carry >> 2
0 10001000
0 01000100