I need to convert a number to hex in perl. I'm using the following simple code:
my $n = 10;
print sprintf("%X", $n);
That will output: A That's correct, but I need always 2 bytes like: 0A
So for example: 90 will show 5A - 6 will show 06 - 10 will show 0A
How can I do that?
sprintf("%02X", $n)
\n
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.