Created
December 15, 2017 13:05
-
-
Save jpluimers/da75280cc974a3f5471c1910dff55902 to your computer and use it in GitHub Desktop.
keeps multiplying by powers of 2 until it finds the widest bitness your system supports
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# related to bytesToHuman.bash | |
# 64-bibt checks at https://superuser.com/questions/1030122/what-is-the-maximum-value-of-a-numeric-bash-shell-variable/1030129#1030129 | |
# perpetual while loop: https://stackoverflow.com/questions/10797835/while-vs-while-true | |
# expressions: http://tldp.org/LDP/abs/html/arithexp.html | |
# comparisons: http://tldp.org/LDP/abs/html/comparison-ops.html | |
b=1 | |
n=1 | |
while : | |
do | |
# loop infinitely | |
printf "%3s %40s\n" "$b" "$n" | |
b=$(( 1+$b )) | |
t=$n | |
n=$(( 2*$n )) | |
if (( $n < $t )); then | |
exit | |
fi | |
done | |
echo "the final number on the left is the largest bitness; on the right the largest power of 2 your system supports" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment