answersLogoWhite

0

Can we perform bitwise circular shift in c?

Updated: 8/20/2019
User Avatar

Wiki User

11y ago

Best Answer

Yes:

unsigned char CircLeft (unsigned char value)

{

if (value&0x80) return (value<<1) + 1;

else return (value<<1);

}

unsigned char CircRight (unsigned char value)

{

if (value&0x01) return (value>>1) + 0x80;

else return (value>>1);

}

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Can we perform bitwise circular shift in c?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the use of bitwise operator in c plus plus?

They perform bitwise operations like AND (&amp;), OR (|), XOR (^) and NOT (~).


What are Bit Manipulations in C programming?

in C you can manipulate the individual bits of a data item. &lt;&lt; leftwise shift &gt;&gt; rightwise shift &amp; bitwise AND | bitwise OR ~ bitwise complement (flips all bits) I can't go intoa tutorial here in how to use these, but google it - i just did and there's tons of info out there.


Which is the code to multiply a number num1 by 2 using bitwise operator in c?

num1 &lt;&lt;= 1; /* shift left */


What is use of l in c language?

Bitwise OR.


What is the meaning of and in C programming language and when is it used?

logical and: exp1 &amp;&amp; exp2 means: exp1==0 ? 0 : exp2==0 ? 0 : 1


What are the various operators available in c language?

There are eight types of operators which are used in C language.These are- 1.Arithmetic operator 2.Assignment operator 3.Relational operator 4.Increment/Decrement operator 5.Bitwise operator 6.Logical operator 7.Conditional operator 8.Additional operator 1.Arithmetic operator:Arithmetic operators are mathmetical operator.These are addition,Subtraction,Multiplication and divison. 2.Assignment operator:Assignment operators are used to store the result of an expression to a variable.


How many types of logical operators in c only?

There are three logical operators in C; AND (&amp;), OR (|), and NOT (^). These are the bitwise versions. The combinatorial versions are &amp;&amp;, , and !.


What are logical classes in c plus plus?

There is no such thing. Logic is bitwise operation, not a data type.


What is operator associativity in C?

OperatorDescriptionAssociativity()[].->++ -- Parentheses (function call) (see Note 1)Brackets (array subscript)Member selection via object nameMember selection via pointerPostfix increment/decrement (see Note 2) left-to-right++ --+ -! ~(type)*&sizeof Prefix increment/decrementUnary plus/minusLogical negation/bitwise complementCast (change type)DereferenceAddressDetermine size in bytes right-to-left * / % Multiplication/division/modulus left-to-right + - Addition/subtraction left-to-right > Bitwise shift left, Bitwise shift right left-to-right < >= Relational less than/less than or equal toRelational greater than/greater than or equal to left-to-right == != Relational is equal to/is not equal to left-to-right & Bitwise AND left-to-right ^ Bitwise exclusive OR left-to-right | Bitwise inclusive OR left-to-right && Logical AND left-to-right Logical OR left-to-right ?: Ternary conditional right-to-left =+= -=*= /=%= &=^= |== AssignmentAddition/subtraction assignmentMultiplication/division assignmentModulus/bitwise AND assignmentBitwise exclusive/inclusive OR assignmentBitwise shift left/right assignment right-to-left ,Comma (separate expressions) left-to-right


How do you swap two numbers with bitwise operator in c plus plus?

// Note: ^ is the XOR operator a = a ^ b b = b ^ a a = a ^ b


How is a bitwise copy created in c plus plus?

You could just use memcpy(3), using sizeof() to get the object size.


How do you Swap two numbers using bitwise operator C?

//lets assume a = 10; b = 20; a = a^b; b = a^b; a = a^b;