answersLogoWhite

0

If i is an unsigned char (1 byte unsigned integer) then:

i (i << 4) | (i >> 4);

If you know how to write inline assembly on your compiler (it differs between compilers), then rotating the byte is much more straightforward way to swap nibbles. In Intel assembly, it would look like:

ror i, 4

So in Microsoft compilers it would look like:

__asm

{

ror i,4

}

User Avatar

Wiki User

9y ago

What else can I help you with?

Related Questions

How do you swap two variables using bitwise operators?

a := a XOR b b := a XOR b a := a XOR b it works, but never use it in real programs do you know why its not used in real program??


How do you swap two variables using airthematic operators?

a += b; b -= a; a -= b;


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;


How do you write a javascript to swap two numbers without using third one?

By using the algorithm of bitwise EORing (Exclusive ORing) the numbers together:If the two numbers are X and Y, then to swap them:X = X EOR YY = Y EOR XX =X EOR Ywill swap them.With knowledge of that algorithm, one then uses the syntax of Javascript to implement it.


How do you swap two numbers without using third one using pointers?

How do you do. I am doing well thank you. Swap two number by using reference operators A tough assignment, it will make you think. I think you are confusing reference operators with pointers. Were I you I would study the section on pointers in your text book or course material.


What are the conditions to swap in c plus plus without temporary?

You can swap two integers without temporary storage by bitwise exclusive-or'ing them in a specific sequence...a ^= b;b ^= a;a ^= b;


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


Obtain algorithm that corresponds a program for the interchange of two numerical variable values?

In general, to swap two variables A and B with each other, you need a third variable T of the same type. You then perform the sequence T = A, A = B, and B = T. For the special case where A and B are binary types, you can swap them without a temporary variable using a bit-wise exclusive or operator. Using C/C++ syntax, you would use the sequence A ^= B, B ^= A, and A ^= B. For this to succeed, the exclusive or operator (^) must be bitwise. Actually, it is also possible to swap any two arbitrarily typed variables, such as float or object, so long as you can properly do the bitwise exclusive or operation, perhaps by doing typcasts or by playing games with pointers - although any of that is potentially dangerous and not always portable.


Can you win in Uno by using a Swap Hands card?

No, you cannot win in Uno by using a Swap Hands card.


What is program in c to swap entered two numbers without using third variable?

The required c program is given below /*Swapping(interchange) the two entered numbers*/ #include&lt;stdio.h&gt; main() { /*Without using third variable*/ int a,b,t; printf("Enter a:"); scanf("%d",&amp;a); printf("Enter b:"); scanf("%d",&amp;b); a=a+b; b=a-b; a=a-b; printf("\n After swapping without using third variable"); printf("\na=%d\nb=%d",a,b); }


How do you swap change the digital dash to analog in your 85 thunderbird?

by using some of the converters we can swap the analog dash into digital


Write a program to swap two numbers using function?

swap (int *a, int *b) { *a ^= *b; *b ^= *a; *a ^= *b; }