My Scripts.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
bin/binary

10 lines
207 B

#!/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