16 lines
472 B
Bash
16 lines
472 B
Bash
#!/bin/bash
|
|
|
|
function g_percentage-diff {
|
|
local g_from=$1
|
|
local g_to=$2
|
|
unset g_percentage_diff_result
|
|
g_num_valid_number "$g_from" "$g_to" || return 1
|
|
g_calc "${g_from} == 0"
|
|
[ ${g_calc_result} -eq 1 ] && return 1
|
|
g_calc "${g_to} == 0"
|
|
[ ${g_calc_result} -eq 1 ] && return 1
|
|
g_calc "100/${g_from}*(${g_to}-${g_from})"
|
|
#g_percentage_diff_result=$(printf -- "%.2f" "${g_calc_result}")
|
|
printf -v g_percentage_diff_result -- "%.2f" "${g_calc_result}"
|
|
}
|