internetuser2k12
Banned
- Joined
- Jul 25, 2012
- Messages
- 1,192
- Helped
- 171
- Reputation
- 342
- Reaction score
- 162
- Trophy points
- 1,343
- Activity points
- 0
Hello!
I have a code for BCD to Decimal conversion of date and time
sec and minutes both vary from decimal 0 to 59 and bcd 0x00 to 0x59. Then why is the formula for sec and time bcd to decimal transformation is different?
For seconds it is *sec = ((*sec & 0x70 ) >> 4)*10 + (*sec & 0x0F);
For minutes it is *min = ((*min & 0xF0 ) >> 4)*10 + (*min & 0x0F);
I have a code for BCD to Decimal conversion of date and time
Code:
*sec = ((*sec & 0x70) >> 4)*10 + (*sec & 0x0F);
*min = ((*min & 0xF0) >> 4)*10 + (*min & 0x0F);
*hr = ((*hr & 0x30) >> 4)*10 + (*hr & 0x0F);
*week_day =(*week_day & 0x07);
*day = ((*day & 0xF0) >> 4)*10 + (*day & 0x0F);
*mn = ((*mn & 0x10) >> 4)*10 + (*mn & 0x0F);
*year = ((*year & 0xF0)>>4)*10+(*year & 0x0F);
sec and minutes both vary from decimal 0 to 59 and bcd 0x00 to 0x59. Then why is the formula for sec and time bcd to decimal transformation is different?
For seconds it is *sec = ((*sec & 0x70 ) >> 4)*10 + (*sec & 0x0F);
For minutes it is *min = ((*min & 0xF0 ) >> 4)*10 + (*min & 0x0F);