I need to convert a very big number in its hex form (no spaces, no anything e.g. 8ac7230489e80001). Using printf gives an out of range error.
printf '%x\n' "24267339429148234667523"
-bash: printf: warning: 24267339429148234667523: Numerical result out of range
ffffffffffffffff
I tried other methods (python), but it seems they only give a string output. I still need it to be a number. Is it possible to handle numbers larger like this?
CodePudding user response:
Decimal to hex:
echo 'obase=16; 24267339429148234667523' | bc
and the other way around:
echo 'ibase=16; 52388FCBCEF833CD603' | bc
CodePudding user response:
You can use the bc utility:
bc <<< 'obase=16;24267339429148234667523'
