answersLogoWhite

0


Best Answer

main()

{

int num=0xABCD;

printf("%x\n",num);

int rev=0x0;

int digit=0x0;

while(num!=0x0)

{

digit=num%0x10;

rev = rev*0x10 +digit;

num=num/0x10;

}

printf("%x\n",rev);

}

User Avatar

Wiki User

16y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How to Reverse a hexadecimal number using bitwise?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Write a Program to convert decimal number into hexadecimal no without using function and string?

This is not a question.


How do you convert 35 into 53 using bitwise operators?

22 XOR 35 = 53Note that the value 22 is a magic number because it only works for the values 35 and 53. The value 22 was calculated as follows:35 XOR 53 = 22It can also be seen that:22 XOR 53 = 35It is assumed that you are actually looking for some bitwise operation that will reverse the digits in any number. You cannot do this because in order to determine the magic number for any given value, you first need to XOR the value with the reverse of the value, which means you must already know the reverse of the value.To reverse any value that is not a multiple of 10, use the following function:unsigned reverse (unsigned num) {unsigned rev;rev = 0;while (num) {rev *= 10;rev += num % 10;num /= 10;}return rev;}Note that reverse(10) is 1, not 01. If you want to convert trailing zeroes into leading zeroes, convert the number to a string and then reverse the string, returning the string rather than the numeric value.


Why people are using Hexadecimal rather than binary numbers while doing programs?

hexadecimal can express 16 bit binary in 4 place form, not 16.


How do you convert a number that consist of alphabet and number in reverse order?

To reverse a number, first convert the number to a string, then reverse the string. Given your number consists of alphanumeric characters, the number must already be a string so simply reverse the string: #include<string> using std::string; string reverse (const string& s) { string str {}; for (auto c : s) str.insert (str.begin(), c); return str; } int main () { std::cout << "Enter a number: "; string s {}; std::cin >> s; std::cout << "The number in reverse is: " << reverse (s); }


What is the use of Bitwise operators?

AnswerThe bitwise operators treat a number as its binary equivalent rather than as a simple boolean value.For most programming languages, a value of zero is considered FALSE and all other values are TRUEThus, 8 AND 11 returns TRUE as does 3 OR 0In bitwise analysis, each binary bit of the digit are compared. The number of bits compared will depend on the type of number.In C, a CHAR is usually 8 bits and can hold the binary numbers 0 to 255.If we compare 8 (00001000) and 19 (00010011) with bitwise operators, we get different results from Boolean operators:8 BITWISE AND 19 returns 0 (each bit in the response is set to 1 if both equivalent bits compared are 1) but 8 BITWISE OR 19 will return 27.The utility of these methods is in identifying binary data. For example, all files on a PC have the characteristics 'Hidden' 'Read Only' 'Archive' and 'System' which can be set or unset using bitwise operations on a single byte of data. In truth this is a throwback to the days of small memory capacities where saving the odd byte was essential.There are more uses of bitwise, especially in graphics, where XOR can be used to paint a sprite image to display it and then be used again to return a background to its former settings. I regret I lack the skill to explain this better.

Related questions

What is hexadecimal number?

The hexadecimal number system is one using 16 as the base instead of the more familiar ten which we use in the decimal system.


What is Hexadecimal Number systeam?

The hexadecimal number system is one using 16 as the base instead of the more familiar ten which we use in the decimal system.


When you count to 15 using hexadecimal numbers the highest number is what?

The answer is 15.


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

num1 <<= 1; /* shift left */


Write a Program to convert decimal number into hexadecimal no without using function and string?

This is not a question.


What is the equivalent hexadecimal number for 13?

13 = D in hex. If you're using two digits to represent the hex number - its 0D


What are the steps for using a free reverse phone number lookup?

The steps for using a free reverse phone number lookup are: go to a website like Reverse Number Direct, type in the relevant information and then you'll get results.


How do you convert 35 into 53 using bitwise operators?

22 XOR 35 = 53Note that the value 22 is a magic number because it only works for the values 35 and 53. The value 22 was calculated as follows:35 XOR 53 = 22It can also be seen that:22 XOR 53 = 35It is assumed that you are actually looking for some bitwise operation that will reverse the digits in any number. You cannot do this because in order to determine the magic number for any given value, you first need to XOR the value with the reverse of the value, which means you must already know the reverse of the value.To reverse any value that is not a multiple of 10, use the following function:unsigned reverse (unsigned num) {unsigned rev;rev = 0;while (num) {rev *= 10;rev += num % 10;num /= 10;}return rev;}Note that reverse(10) is 1, not 01. If you want to convert trailing zeroes into leading zeroes, convert the number to a string and then reverse the string, returning the string rather than the numeric value.


What a hexadecimal code?

It is a representation of numbers using 16 as the base.


What benefit can using a reverse search phone number have?

When using a reverse search phone number the person you are calling can tell who you are without having to look you up manually, this will increase the chances of calls from reputable companies being answered.


Is the ip address format expressed using four octets of hexadecimal numbers?

no


What does hexadecimal means?

It means using 16 as the base for counting.