Question

Using 8 bit registers and signed magnitude representation. I thought 25 in BCD is 010 0101 but my text book says it as 001 1001. Can somebody explain?

Was it helpful?

Solution

25 / 2 = 12r1 (12 with a remainder of 1)

12 / 2 = 6r0 (6 with a remainder of 0)

6 / 2 = 3r0 (3 with a remainder of 0)

3 / 2 = 1r1 (1 with a remainder of 0)

1 / 2 = 0r1 (0 with a remainder of 0)

So 11001 (working backward up the tree) is the binary equivalent to 25.

Another way to think about it is with powers of 2:

(1*16) + (1*8) + (0*4) + (0*2) + (1*1) = 25

And it's worth noting, just as in base 10, leading zeros do not change the value of a number. (00025 == 25) (0011001 == 11001).

The leading zeros are there in your case because your needing to populate an 8 bit register (there needs to be 8 binary digits regardless of their value).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top