I have a routine that is collecting a hex value via SNMP. Here is a real collection from my bash script 08 01 18 00 FF FF. The value is base on expr $((16#${array[4]})) - $((16#${array[5]})) so the results are 0, how do I introduce two is complement? The correct value for expr $((16#${array[4]})) - $((16#${array[5]})) is -1 based on the example I am working on.
相关问题
- JQ: Select when attribute value exists in a bash a
- bash print whole line after splitting line with if
- “command not found” errors in expect script execut
- grep using grep results
- UNIX Bash - Removing double quotes from specific s
相关文章
- 关于C#中 float、double、decimal 的运算不精确的问题。
- Check if directory exists on remote machine with s
- MYSQL: DECIMAL with accuracy of 10 digits after th
- Reverse four length of letters with sed in unix
- How to convert hex string into decimal value
- Launch interactive SSH bash session from PHP
- BASH: Basic if then and variable assignment
- Bash script that creates a directory structure
For convenience, let's create a bash function:
Now:
Converting multiple values in one call
Define an eXtended two's complement function:
Sample usage: