You are on page 1of 2

The basic algorithm is split the value into 4 bits each and add by 6

see now you can do this when the value is above 9 , because in BCD you
can represent from 0-9 only.

I pad zeros before msb to make it look like 4 bits

Converting 10 to BCD

Binary of 10 -- 1 0 1 0
6 -- 0 1 1 0
------------
0 0 0 1 0 0 0 0 // the carry is padded with “0”.

1 0

Converting 16 to BCD

Binary of 16 -- 1 0 0 0 0

pad it with zero -- 0 0 0 1 0 0 0 0

split above bits into 4 bits each.

0 0 0 1 0 0 0 0
+ 0 1 1 0
---------
0 1 1 0
now
0 0 0 1 0 1 1 0 // NO carry generated

1 6

Converting 20 to BCD

Binary of 20 -- 1 0 1 0 0

pad it with zero -- 0 0 0 1 0 1 0 0

split above bits into 4 bits each.

0 0 0 1 0 1 0 0
+0 1 1 0
---------
1 0 1 0 -> the ans is above 9 again add it with 6
+0 1 1 0
---------
0 0 0 1 0 0 0 0 // Carry is added with the Spilt MSB
+0 0 0 1
------------
0 0 1 0 0 0 0 0

2 0

You might also like