Page 1 of 2
Hexedecimal Why?
Posted: Fri May 31, 2013 1:11 pm
by computertrick
This is likely a stupid question but what is the point of hexadecimal because it is a lot easier to read decimal than hexadecimal because you have to preform more calculations to get a decimal value for example
FFFF
15 * 16 + 15 * 16 + 15 * 16 + 15 = 65535
Please no harsh comments I'm just trying to understand because to me 65535 is much easier to read than FFFF
Re: Hexedecimal Why?
Posted: Fri May 31, 2013 1:21 pm
by Combuster
Because hexadecimal is all about meaning.
FFFF is 16 set bits.
65535 is... a meaningless magic number?
Re: Hexedecimal Why?
Posted: Fri May 31, 2013 1:26 pm
by computertrick
Combuster wrote:Because hexadecimal is all about meaning.
FFFF is 16 set bits.
65535 is... a meaningless magic number?
Lets say I wanted to access another part in memory I would have to calculate another hexadecimal value rather than just add to the decimal number
Re: Hexedecimal Why?
Posted: Fri May 31, 2013 1:34 pm
by iansjack
Well, if you don't like hexadecimal don't use it. It's not compulsory. It just makes life easier.
Re: Hexedecimal Why?
Posted: Fri May 31, 2013 1:37 pm
by AJ
Hi,
Decimal is better for some things, binary for others. Hexadecimal is an extremely useful method of representing bit patterns (and powers of 2) once you get used to it.
Cheers,
Adam
Re: Hexedecimal Why?
Posted: Fri May 31, 2013 1:56 pm
by DavidCooper
I'm a big fan of working with decimals, but for communications with PCI devices, I do all of that in hex. When it comes to decimal addresses, although I use decimals, I keep them divided up in bytes such that I use 255 255 instead of 65535. This means that I'm really working in a mixture of decimals and base 256. 65536 is easy to learn, but would you recognise the significance of 163840 or 49152 at a glance? Unless you have savant-like abilities with numbers, I doubt it.
Re: Hexedecimal Why?
Posted: Fri May 31, 2013 2:00 pm
by gusc
Let's put it like this -digital electronics work with numbers that are represented in bits (either 1 or 0). Computer memory can be accessed only in bytes (8 bits, decimal 0-255 or hex 0x00-0xFF). Now the part that makes hex so much readable than dec is that every 2 hex digits always represen a single byte value (8bits) whereas it takes 1-3 decimal digits to do the same.
Here are some examples:
Bin 0000-1111 , hex 0x0F, dec 15
Bin 1111-0000 , hex 0xF0, dec 240
Bin 0000-0010 , hex 0x02, dec 2
Now, once you need to look at some memory region it becomes a lot easier to look at the pair of digits than some mass of 1-3 ones.
Re: Hexedecimal Why?
Posted: Fri May 31, 2013 11:35 pm
by tom9876543
If you couldn't work out the advantages of hexadecimal, its highly likely you will never be able to build an Operating System.
Re: Hexedecimal Why?
Posted: Fri May 31, 2013 11:35 pm
by linguofreak
As others have said, computers use binary, and a given number of hexadecimal digits always corresponds to the same number of bits (namely, 4 bits per digit), which isn't the case with decimal, and the bit patterns are often more important than the actual numbers (and even when the actual numbers are important, it's often powers of two that are important).
It's easier to figure out how these numbers are related in hex than in decimal:
00000FFF = 4095
FFFFF000 = 4294963200
Re: Hexedecimal Why?
Posted: Sat Jun 01, 2013 1:11 am
by BMW
computertrick wrote:This is likely a stupid question but what is the point of hexadecimal because it is a lot easier to read decimal than hexadecimal because you have to preform more calculations to get a decimal value for example
FFFF
15 * 16 + 15 * 16 + 15 * 16 + 15 = 65535
Please no harsh comments I'm just trying to understand because to me 65535 is much easier to read than FFFF
Decimal is much easier to read than hexadecimal.
That's only because you grew up with decimal. If you use hex enough, it will become easier to read. If you were brought up using only hex numbers, you would think decimal is hard to read.
Re: Hexedecimal Why?
Posted: Sun Jun 02, 2013 5:56 pm
by Jezze
As previously mentioned hexadecimal is simple for understanding what bits are set and which are not but I want to add something a bit off-topic.
There is a something called duodecimal which is just base 12. It would actually be a base much simpler to use in everyday life compared to base 10 which we have today. I think there is even some group or organization trying to promote this.
The reason is simple. Base 12 is simple to use for stuff like division because you easily get halfs, thirds, forths and sixths. There are some other good reasons to for working out the clock etc.
This explains it a bit better:
http://www.youtube.com/watch?v=U6xJfP7-HCc
Re: Hexedecimal Why?
Posted: Sun Jun 02, 2013 7:07 pm
by TightCoderEx
Consider this
memory board, populated with 32 2114 static ram chips. Each chip has 4K bits, so the way this card is configured there are 4 banks 8 bits wide, hense 8 IC's for each bank, thus yielding 16K actually 16,384 or 4000H bytes. Our memory diagnostic indicated that @ location 24C1 we wrote FF, but got CF back. This means that both chip # 3 and 4 (left to right) are damaged and location 4C1 (1217). As we have 4 indentical locations in each bank, the 2 tells us the problem ICs are in bank 3 (second row, right set).
This is an over simplification and I don't even know if board is hardwired in that manner, but the example does demonstrate the value of HEX in determining which IC(s) to change. Base 16 would also have played a very significant part in designing decoder and latch configurations to make this card work.
So you can see by simply shifting address right 12 bits, we're left with the bank where the problem is.
What relevance has this today, probably less than none, because it's been a long time since I've seen a card where the ICs can be changed, but in modern programming there is a lot of attention paid to structure and stack alignment on qword boundaries. At a simple glance, is 5976 evenly divisible by 8 or 191262. Yes and No respectively as it's easy to see 1758 bits 2,1,0 are null and 2EB1E are not, which is what is required for an address to be qword aligned.
Re: Hexedecimal Why?
Posted: Mon Jun 03, 2013 1:13 am
by rdos
Hex is also very useful when laying out fixed linear addresses, that often should be page-aligned. You cannot easily determine / verify if a decimal address aligns to a page or not, while it is easy when using hexadecimal addresses. You cannot even easily determine if a decimal address is qword aligned.
Re: Hexadecimal Why?
Posted: Mon Jun 03, 2013 1:35 pm
by DavidCooper
I've only ever used one hex editor, so it may not be representative of the norm, but HxD only appears to be able to give you the sector number as a decimal value. I find that really annoying as I keep having to reach for a calculator to work out where things are.
Re: Hexedecimal Why?
Posted: Tue Jun 04, 2013 8:39 am
by greyOne
In a nutshell, (and my opinion)
Hex is a convenient way of bundling 4 binary digits into 1.
This is highly relevant since computers understand binary, not base 10.
Nor hex for the matter, but conversion between bases 2 and 16 is much easier than that of 10.
You can use any base really.
You can even use base 7. Although I strongly advise against the idea.
Might be relevant to the fact the root of 16 is 4, whereas the root of 10 is... 3.162277..etc.
Which happens to be the exact number of binary digits that are represented by a single decimal digit.
Sure, Hex is hard to get used to,
But when you're working with bitflags or addresses,
It's truly a beautiful thing.