BCD

Introduction

BCD code (Binary-Coded Decimal) is also known as binary-coded decimal number or binary-decimal code.

This coding method utilizes four bits to store a decimal digit, enabling quick conversion between binary and decimal.

Usage

String strForTest = "123456ABCDEF";

// Convert to BCD
byte[] bcd = BCD.strToBcd(strForTest);

// Decode BCD
String str = BCD.bcdToStr(bcd);