|
|
|
|
|
by binaryapparatus
2717 days ago
|
|
function convert-decimaltobinary(){
n="$1"
bit=""
while [ "$n" -gt 0 ]; do
bit="$(( n&1 ))$bit";
: $(( n >>= 1 ))
done
printf "%s\n" "$bit"
}
function convert-binarytodecimal(){
echo "$((2#$1))"
}
function convert-hextodecimal(){
echo $(( 16#$1 ))
}
|
|