Markus
2010-07-01 14:13:20 UTC
Hi,
I am facing a problem when interpreting negative decimal number in
hexadecimal format using 'printf' in bash script.
This example command:
printf "%X\n" -2147476746
Does produce this result: FFFFFFFF80001AF6.
I learned that the 'FFFFFFFF' is an interpretation of the minus sign.
Now I would like to do the opposite conversion, Hex2Dec
printf "%d\n" 0xFFFFFFFF80001AF6
Result is "-bash: printf: warning: 0XFFFFFFFF80001AF6: Numerical
result out of range" plus some long number. But I am awaiting the
original number -2147476746.
So the question is - how do I convert the negative hexadecimal value
back to the original value?
I am facing a problem when interpreting negative decimal number in
hexadecimal format using 'printf' in bash script.
This example command:
printf "%X\n" -2147476746
Does produce this result: FFFFFFFF80001AF6.
I learned that the 'FFFFFFFF' is an interpretation of the minus sign.
Now I would like to do the opposite conversion, Hex2Dec
printf "%d\n" 0xFFFFFFFF80001AF6
Result is "-bash: printf: warning: 0XFFFFFFFF80001AF6: Numerical
result out of range" plus some long number. But I am awaiting the
original number -2147476746.
So the question is - how do I convert the negative hexadecimal value
back to the original value?