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.
- Division produces a number, not a string. You should be expecting the result to be zero, not a string.
- Hex is a text representation of a number. X'00' represents the number zero, not a string.
print sprintf("%02X ", ord($result2)) . "\n";
print sprintf("%02X ", $result2) . "\n";