# - loosely based on the function "round()", taken from
# - inspired by user85321 @ askubuntu.com (original author)
# and Aquarius Power
# the round function (alternate approach):
# if negative, negate value ...
(( $(bc <<<"$v < 0") == 1 )) && v=$(bc <<<"$v * -1")
# ... however, since value was only negated to get correct rounding, we
# have to add the minus sign again for the resulting value ...
(( $(bc <<< "$vorig < 0") == 1 )) && r=$(bc <<< "$r * -1")
env printf %.$3f $r
echo "Insert the price you want to calculate:"
echo "This is the price without taxes:"
round2 $float 1.18 2
echo && read -p "Press any key to continue..."
It is actually simple: there is no need to explicitly add a hardcoded "-0.5" variant for negative numbers. Mathematically spoken, we'll just compute the absolute value of the argument and still add 0.5 as we normally would. But since we (unfortunately) have no built-in
abs() function at our disposal (unless we code one), we will simply negate the argument if it's negative.
Besides, it proved very cumbersome to work with the quotient as a parameter (since for my solution, I must be able to access the dividend and divisor separately). This is why my script has an additional third parameter.