baumi's blog

baumi's personal blog … Linux, OS X, Windows, Random things, …

Bash cast unsinged integer to signed int (int, uint, int64, uint64)

printf "0x%x" $(( 18446744073709397316 ))

output:
0xfffffffffffda544

then:

printf "%d" $(( 0xfffffffffffda544 ))

output:

-154300

short versions:

printf “%d” $(( 18446744073709397316 ))
echo $(( 18446744073709397316 ))

output:

-154300
-154300

Comments are currently closed.