Reputation: 49
I am a student and studying about binary and hexadecimal.I want to know why we need to convert binary number to hexadecimal number.What is its use in real life?
Upvotes: 0
Views: 943
Reputation: 15172
If you are stuck using a pre-c++14 compiler you won't have binary literals available except as an extension. Even then since 4 binary digits is always equivalent to 1 hex digit it is often easier to get long constants right by using hex instead of binary. (imagine for instance writing the 33 binary digits needed to get 0x100000000, it would be easy to miss a 0 or insert an extra).
Upvotes: 2
Reputation: 275820
There are 10 different kinds of people, those who understand binary, those who don't, and those who realize this joke is in trinary.
People are better at handling fewer symbols of more types. Computers are designed to handle 2 symbols (0 and 1) and lots of them.
Hex is a useful format, because it uses fewer symbols and more types, but it is easy to convert to/from binary. So when you want to examine binary, or input it, hex is highly useful for humans.
It is usually better than octal (base 8) because each hex digit is 4 bits, and binary data is usually arranged in clumps of powers of 2 due to how our computer bit-addressing works. So you'll have 8 bit bytes, 16 byte words, 32 byte double words and 64 byte quad words; this comes out to 2, 4, 8 and 16 hex digits.
As each octal digit is 3 bits, and 3 doesn't divide any power of 2, this doesn't work out as neatly for common binary bit clumps we manipulate.
This answer assumes "real life" is "working with computers". From programming down to picking colors on a web page, you'll use hex while doing this.
Upvotes: 7