Fixed /nice' display breaking the actual maths!

This commit is contained in:
Rob Pearce 2022-08-29 11:26:55 +10:00
parent 64ac879faa
commit 80eaa5ee9a
1 changed files with 3 additions and 11 deletions

View File

@ -65,11 +65,7 @@ if [[ $mode == "s" ]]; then
diagram="${diagram}[server]\n" diagram="${diagram}[server]\n"
eq="${eq} * 100" eq="${eq} * 100"
answer=$(echo "scale=9; $eq" | bc) answer=$(echo "scale=9; $eq" | bc)
if [[ $answer == 99.* ]]; then answershort=$(echo "$answer" | sed 's/\(\.[^0]\+\)0\+/\1/')
answershort=$(echo "$answer" | tr -dc '9.')
else
answershort=$answer
fi
if [[ $answershort == 99.* ]]; then if [[ $answershort == 99.* ]]; then
nines=$(echo $answershort | tr -d -C 9 | wc -c | tr -d ' ') nines=$(echo $answershort | tr -d -C 9 | wc -c | tr -d ' ')
[[ $nines -eq 1 ]] && ess="" || ess="s" [[ $nines -eq 1 ]] && ess="" || ess="s"
@ -190,11 +186,7 @@ elif [[ $mode == "p" ]]; then
eq="(1 - (1 - (${sysuptime}/100))^${nsites})*100" eq="(1 - (1 - (${sysuptime}/100))^${nsites})*100"
answer=$(echo "scale=15; $eq" | bc) answer=$(echo "scale=15; $eq" | bc)
if [[ $answer == 99.* ]]; then answershort=$(echo "$answer" | sed 's/\(\.[^0]\+\)0\+/\1/')
answershort=$(echo "$answer" | tr -dc '9.')
else
answershort=$answer
fi
if [[ $answershort == 99.* ]]; then if [[ $answershort == 99.* ]]; then
nines=$(echo $answershort | tr -d -C 9 | wc -c | tr -d ' ') nines=$(echo $answershort | tr -d -C 9 | wc -c | tr -d ' ')
[[ $nines -eq 1 ]] && ess="" || ess="s" [[ $nines -eq 1 ]] && ess="" || ess="s"
@ -214,7 +206,7 @@ elif [[ $mode == "p" ]]; then
echo echo
csecho -e "$WHITE" "^b${UNDERLINE}Availability^p\n" csecho -e "$WHITE" "^b${UNDERLINE}Availability^p\n"
inform "^bEquation:^p ${eq}" inform "^bEquation:^p ${eq}"
inform "^bAvailability:^p ${answershort}% $ninestext)" inform "^bAvailability:^p ${answershort}% $ninestext"
else else
echo "Architecture" echo "Architecture"
echo "------------" echo "------------"