Snippets

Created by Sergio Araújo
# source: https://stackoverflow.com/a/63575958/2571881
# adds leading zeros to numbers (binary or decinal)
# tags: [math, numbers, zeros, utils]
# autoloaded by my zsh config

how_many_bits=$1
read number
zeros=$(( $how_many_bits - ${#number} ))
for ((i=0;i<$zeros;i++)); do
echo -en 0
done && echo $number

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.