@Test
    public void testBcdEncoding() throws Exception {
        byte[] bytes = new byte[] {(byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x91, (byte) 0x23, (byte) 0x45, (byte) 0x67, (byte) 0x89, (byte) 0x10};

        // Parse the input
        ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
        BigInteger bigIntegerValue = readBufferByteBased.readUnsignedBigInteger("test", bytes.length * 8, WithReaderWriterArgs.WithEncoding("BCD"));

        // Check the expected value matches
        Assertions.assertEquals(new BigInteger("12345678912345678910"), bigIntegerValue);

        // Serialize the value again
        WriteBufferByteBased writeBufferByteBased = new WriteBufferByteBased(bytes.length);
        writeBufferByteBased.writeUnsignedBigInteger("test", bytes.length * 8, bigIntegerValue, WithReaderWriterArgs.WithEncoding("BCD"));

        // Check the output matches the original one
        byte[] serializedBytes = writeBufferByteBased.getBytes();
        Assertions.assertArrayEquals(bytes, serializedBytes);
    }
In BCD encoding two digits are always encoded as the hex digits of a byte.

@throws Exception something went wrong
plc4j/spi/src/test/java/org/apache/plc4x/java/spi/generation/UnsignedBigIntegerTest.java