Question:
Simple Binary and Hex Question?
SchweppesAle
2007-09-30 18:40:52 UTC
ok, so my question is how many digits are in an 8bit machine. Is it just 8 digits, or is it 16 since each digit can be either 1 or 2.

Also, I'm not entirely sure i understand Hex still. I understand that for each digit, you would use the power of 16 in order to determine it's value. 16^0, 16^1, etc. however, I'm not entirely sure i Know how to apply it just yet.

For instance, how would I represent the number 1081 in Hex and Binary-Little Endian, and Big Endian. Thanks in advance.
Four answers:
2007-09-30 19:03:20 UTC
8 bits are one byte, or 2^8; that's 256 possible numbers, from 0 to 255.



Hex is actually 16^however many numbers you have). For example, 8 hex numbers can have one of 4,294,967,296 values (16^8).



For the decimal 1081, the hexadecimal value is 439, the binary, 10000111001.



http://www.tonymarston.net/php-mysql/converter.php
G_U_C
2007-10-01 01:57:24 UTC
An 8 bit machine has an 8 bit wide data bus and usually handles 8 bits at a time. (there are exceptions)



"How many digits?" is the wrong question: bits. An 8 bit machine can work on immensely large numbers the same way that you do, 1 digit at a time.



Hex is just grouping binary into groups of 4. Don't let it get complicated.



0101 1010 binary

5 A hexadecimal



Now for the 1081H conversion to binary:

1 => 0001

0 => 0000

8 => 1000

1 => 0001

Group them:

0001 0000 1000 0001B



Big-endian/little endian tells us if the most significant bit comes first or last (leftmost or rightmost)

Wikipedia explains it.
thomasjcollins
2007-10-01 08:15:06 UTC
In response to your additional details:



Your big-endian is almost right, just the 8 is one bit off:

Yours: 0001 0000 0100 0001 = 1041 in hex

Right.: 0001 0000 1000 0001 = 1081 in hex.



Your little-endian is off. It looks like you just reversed the big-endian version. In little-endian, the position of the values change, but the values of individual bit-positions do not change.

what you have: 1000 0010 0000 1000 = 8028 hex.

should be.......: 0001 0100 0000 0001 = 1041 hex.



Keep in mind the difference here is only how the number is stored in memory (see wikipedia article linked above). The easiest way to get a little-endian representation is to start by reversing the hex, then just convert to binary as normal.



Here's a different example (having a 1 on both ends of your example can be a little confusing):

1357 hex to little-endian:

0111 0101 0011 0001 (STORED as 7531 hex)



1357 hex to big-endian:

0001 0011 0101 0111 (STORED as 1357 hex)



hopefully that helps....really read that wikipedia article - it helped me a lot.
ForbiddenPC
2007-10-01 01:56:22 UTC
Well, since each digit can be *either * 1 or 0 but not both at the same time - that should clue you in on the answer to the first question.



Hexadecimal is useful because it can be easily converted to/from binary using groups of four bits. This is commonly referred to as "Binary Coded Hexadecimal"


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Continue reading on narkive:
Loading...