gaboshlib/g_num_is_approx.sh hinzugefügt
This commit is contained in:
parent
6166a25b9d
commit
44afe2cdcd
17
gaboshlib/g_num_is_approx.sh
Normal file
17
gaboshlib/g_num_is_approx.sh
Normal file
@ -0,0 +1,17 @@
|
||||
function g_num_is_approx {
|
||||
|
||||
# check if $1 is in percentage range ($3 and $4) to $2
|
||||
local f_num=$1
|
||||
local f_base=$2
|
||||
local f_percentage_up=$3
|
||||
local f_percentage_down=$4
|
||||
|
||||
# Check for valid decimal number
|
||||
|
||||
g_num_valid_number "${f_num}" "${f_base}" "${f_percentage_up}" "${f_percentage_down}" || return 1
|
||||
|
||||
local f_from=$(echo "${f_base} - (${f_base} / 100 * ${f_percentage_down})" | bc -l)
|
||||
local f_to=$(echo "${f_base} + (${f_base} / 100 * ${f_percentage_up})" | bc -l)
|
||||
|
||||
g_num_is_between ${f_num} ${f_from} ${f_to}
|
||||
}
|
Loading…
Reference in New Issue
Block a user