More format fixing

This commit is contained in:
Rob Pearce 2022-08-29 11:33:09 +10:00
parent 80eaa5ee9a
commit 5f95ba53fa
1 changed files with 2 additions and 2 deletions

View File

@ -65,7 +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)
answershort=$(echo "$answer" | sed 's/\(\.[^0]\+\)0\+/\1/') answershort=$(echo "$answer" | sed '/\./ s/\.\{0,1\}0\{1,\}$//')
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"
@ -186,7 +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)
answershort=$(echo "$answer" | sed 's/\(\.[^0]\+\)0\+/\1/') answershort=$(echo "$answer" | sed '/\./ s/\.\{0,1\}0\{1,\}$//')
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"