Arm/bcd2
From ASMBits
arm/decstr2Previous
Nextarm/normalize
Binary-coded decimal is a method to represent decimal numbers encoded into binary. It uses each group of 4 bits (which can normally represent numbers from 0 to 15) to represent one decimal digit (of values 0 to 9). Thus, the number 10 (or 0xa) is encoded in BCD as 0x10.
Write a function that converts a number into its BCD representation. You are guaranteed that the input number will be between 0 and 15.
Expected solution length: Around 4 lines.
Sample Input
10
Sample Output
0x10
arm/decstr2Previous
Nextarm/normalize