~skiqqy/bin

bin/binary -rwxr-xr-x 207 bytes
c3280652Stephen Cochrane Added sandbox script 6 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
#!/bin/bash
isnum() { awk -v a="$1" 'BEGIN {print (a == a + 0)}' >/dev/null; }

toBinary(){
	local n bit
	for (( n=$1 ; n>0 ; n >>= 1 )); do  bit="$(( n&1 ))$bit"; done
		printf "%s\n" "$bit"
}

toBinary $1