lifelight:
I was wondering when and why we would use hex instead of binary
if computers only understand binary.. why would I choose to send a hex number down an SPI communication if the data sheet to a chip said to send 0's and 1's to pick if you are reading or writing what channel and power etc.
I ask this question as I keep seeing it done
You are not choosing to send HEX or BINARY, you are always sending BINARY.
But, humans read binary very slowly. We read decimal much more quickly.
So, if I ask you, what number do you want to send to the other side, you can either answer "01000001", or "65". Because I am human, I will understand "65" much more quickly. But, in both cases, you will be sending binary "01000001".
But, converting quickly between decimal and binary is not so easy. That's where HEXADECIMAL comes in. Any group of 4 binary digits has a range from 0000 to 1111. If you count the possibilities, that's 2 to the power of 4, which is 16. So, we give each of those possibilities a number. The first 10 are our normal 0 - 9, then we use A, B, C, D, E, F for the other 6.
Data is stored in computers in multiples of 8. That means, each group of 8 bits can easily be represented as 2 HEX digits.
So, in binary we go from "00000000" to "11111111". Giving every 4 bytes a hex number, in HEX we go from "00" to "FF". Every binary number quickly converts to hexadecimal because you just group 4 bits together and write the symbol. In decimal, those same numbers go from 0 - 255. Not so easy. Or for 16 bits, we go from "0000" to "FFFF" in hexadecimal, or 0 - 65535 in decimal. Hexadecimal is much quicker and more compact when we are talking about binary.