When the hex number is relative small, I can use echo 0xFF| mawk '{ printf "%d\n", $1}'
echo 0xFF| mawk '{ printf "%d\n", $1}'
to convert hex to dec.
When then hex number is huge, mawk does not work any more, say echo 0x8110D248 | mawk '{ printf "%d\n", $1}'
echo 0x8110D248 | mawk '{ printf "%d\n", $1}'
outputs 2147483647
(which is equivalent to 0x7FFFFFFF).
If all you need is converting Hex to Decimal, I wonder why you are using mawk
. Can't you do something like
echo 'ibase=16;8110D248' |bc
(this outputs 2165363272
).
bash
can also do this (and zsh and pdksh):
echo $(( 0x8110D248 ))
Output:
2165363272
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.