Print a decimal number
$ printf "%d\n" 5
5
Print as float (default 6 decimal places)
$ printf "%f\n" 5
5.000000
Convert a hex number to decimal
$ printf "%d\n " 0xF
15
Convert a decimal number to Hex
$ printf "0x%X\n " 15
0xF
Convert a decimal number to Octal
$ printf "0%o\n " 8
010
No comments:
Post a Comment