4 ms·
function convert-decimaltobinary(){ n="$1" bit="" while [ "$n" -gt 0 ]; do bit="$(( n&1 ))$bit"; : $(( n >>= 1 )
by binaryapparatus 8y 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 ))
}
- yesenadam 8y agoI think I'll use them more if they're cdb, cbd, chd. Thanks!