/ Published in: C#
BCD is where the hex value of a byte represents two integer values between zero and nine; e.g., 0x98 -> "98" (whereas its integer value is actually 152). The method throws an exception if non-BCD data is input.
There is actually a built-in method to do BCD: System.BitConverter.ToString. Note, though, that BitConverter only uses the endianness of the host machine, so you might need to convert to Big or Little Endian depending on the data source or destination.
Example: `BitConverter.ToString(new byte[] {0xAE, 0xD0})` gives us the string `AE-D0`.
There is actually a built-in method to do BCD: System.BitConverter.ToString. Note, though, that BitConverter only uses the endianness of the host machine, so you might need to convert to Big or Little Endian depending on the data source or destination.
Example: `BitConverter.ToString(new byte[] {0xAE, 0xD0})` gives us the string `AE-D0`.