It's basically the algorithm to break a number down to digits. Then each digit would be represented as a natural binary number on its own.
To break it down to digits, get a remainder after division with 10 (that's the last digit), then divide the number by 10 to remove that digit. Repeat until there are digits, and store each one into an array (or print them to screen without storing).
Chat with our AI personalities
BCD is a decimal number. BCD is one specific way to store decimal numbers in computer memory.
12
1111 can't be used for Binary Coded Decimal (BCD) because 1111=15 which is made of 2 digits 1 and 5. In BCD a 4-digit binary number is used for every decimal digit. ex. 1111 is incorrect 1 = 0001 5 = 0101 Answer: 0001 0101
Well, adding (0110) during BCD addition helps us adjust the result when it exceeds the range of a single BCD digit. It's like adding a little bit of magic to ensure our calculations stay within the limits of BCD representation. Just a little touch of (0110) can make all the difference in keeping our numbers happy and balanced.
BCD, which stands for Binary Coded Decimal. 4 bits are used to code each decimal digit. So we have 0000 for zero, up to 0111 for seven, then 1000 for eight and 1001 for nine. The others {ten through fifteen} are not used, as those numbers are formed from additional decimal digits. So if you wanted to form twelve, in BCD it is 0001 0010, for 12{base ten}