~skiqqy/bin

ref: 8ecc22ceaf02ecaad3c432d7083882458da0e8c5 bin/binary -rwxr-xr-x 207 bytes
8ecc22ceStephen Cochrane Progress on clip 7 months 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