使用 shell 脚本将有符号 int 数转换为无符号数

Son*_*nge 2 bash shell awk sh

我需要使用 shell 脚本将有符号 int32 数字转换为无符号数字

例如 :

convert  Input : -256
Expected output: 4294967040
Run Code Online (Sandbox Code Playgroud)

Mus*_*GRU 5

这可以帮助你;

\n\n
#!/bin/bash\ninput=$1\nif [[ $input -lt "0" ]]; then\n    output=$((4294967296+$input))\nelse\n    output=$input\nfi\necho $output\n\n\n#signed int32;\n#\xe2\x80\x932,147,483,648 to 2,147,483,647\n#unsigned int32\n#0 to 4,294,967,295\n
Run Code Online (Sandbox Code Playgroud)\n