internetuser2k12
Banned

Hello!
I want to know how this BCD to Decimal code works.
Should I have to give 0x99 for year 99 for bcd in the formula to get 153 decimal
i.e., (bcd >> 4) = 0x99 >> 4 = 0x09 or d9
(bcd >> 4)*10 = 0x09 * d10 = 0x90 or d144
(bcd & 0x0F) = 0x99 & 0F = 0x09 or d9
finally 0x90 + 0x09 = 0x99 or d144 + d9 = d153.
I have confusion here (bcd >> 4)*10 = 0x09 * d10 = 0x90 or d144 does it calculate 0x90 * d10 or 0x90 * 0x0A? I think it calulates 0x90 * d10 because 10 is written as 10 and not 0x10 or 0x0A. Am I right?
I want to know how this BCD to Decimal code works.
Code:
((bcd >> 4)*10+(bcd & 0x0F));
Should I have to give 0x99 for year 99 for bcd in the formula to get 153 decimal
i.e., (bcd >> 4) = 0x99 >> 4 = 0x09 or d9
(bcd >> 4)*10 = 0x09 * d10 = 0x90 or d144
(bcd & 0x0F) = 0x99 & 0F = 0x09 or d9
finally 0x90 + 0x09 = 0x99 or d144 + d9 = d153.
I have confusion here (bcd >> 4)*10 = 0x09 * d10 = 0x90 or d144 does it calculate 0x90 * d10 or 0x90 * 0x0A? I think it calulates 0x90 * d10 because 10 is written as 10 and not 0x10 or 0x0A. Am I right?