Printf notes: Difference between revisions
From Federal Burro of Information
Jump to navigationJump to search
No edit summary |
No edit summary |
||
Line 14: | Line 14: | ||
</pre> | </pre> | ||
binary: ( | binary with bc: (printf can't do this) | ||
<pre> | <pre> | ||
Line 26: | Line 26: | ||
# No need of ibase=10, because default ibase is 10. | # No need of ibase=10, because default ibase is 10. | ||
</pre> | </pre> | ||
== Also see == | == Also see == |
Latest revision as of 16:14, 10 May 2013
hex:
mitsor-bpe01:/etc # printf "%.8x\n" 13 0000000d mitsor-bpe01:/etc # printf "%.8x\n" 14 0000000e mitsor-bpe01:/etc # printf "%.8x\n" 15 0000000f mitsor-bpe01:/etc # printf "%.8x\n" 16 00000010 mitsor-bpe01:/etc #
binary with bc: (printf can't do this)
#NOTE: Using bc command you can directly get output at command line. # $ echo 'obase=2;15' | bc # 1111 # $ echo 'obase=2;1023' | bc # 1111111111 # $ echo 'obase=2;1024' | bc # 10000000000 # No need of ibase=10, because default ibase is 10.