If it won't be simple, it simply won't be. [Hire me, source code] by Miki Tebeka, CEO, 353Solutions

Friday, October 23, 2009


# Show binary representation of a number

if [ $# -ne 1 ]; then
echo "usage: `basename $0` NUMBER" 1>&2
exit 1

echo "obase=2; $1" | bc -l

1 comment:

Adam Monsen said...

This is a handy trick to get an idea of what small, unsigned whole-number decimals might look like as binary. Nice!

Actual binary representation, however, is best left to hardware implementers. :)

Blog Archive