http://www.perlmonks.org?node_id=1205802


in reply to hexadecimal division

What I expect is 5/16 converted to an int which is the NUL characted (0x00) which the API show as X'00'.

Two errors in there.

  1. Division produces a number, not a string. You should be expecting the result to be zero, not a string.
  2. Hex is a text representation of a number. X'00' represents the number zero, not a string.

Replace

print sprintf("%02X ", ord($result2)) . "\n";
with
print sprintf("%02X ", $result2) . "\n";