I have to convert a Number of Type Long in C to a BCD (Binary Coded Decimal) Number with 4 Bits each. I can only use Bitwise shifting and Bitoperations. Can anyone help me achiving this. At the moment i have no idea how to reach my goal.
unsigned long convertBinaryToBCD(unsigned long number){
int number_t_conv = number;
int num_digit = 0;
int count_digits = countNumberDigits(number);
for(num_digit = 0; num_digit <= count_digits; num_digit++){
}
return (((number_t_conv/100) << 8) | ((number_t_conv/10) << 4) | (number_t_conv % 10));
};