# round()
# {
#   # shellcheck disable=SC2312
#   echo "$(printf %.$2f "$(echo "scale=$2;(((10^$2)*$1)+0.5)/(10^$2)" | bc)")"
# }

round() {
  # $1 is expression to round (should be a valid bc expression)
  # $2 is number of decimal figures (optional). Defaults to three if none given
  df=${2:-3}
  # shellcheck disable=SC2312
  printf '%.*f\n' "${df}" "$(bc -l <<EOF
a=$1; if(a>0) a+=5/10^(${df}+1) else if (a<0) a-=5/10^(${df}+1); scale=${df}; a/1
EOF
)"
}

# round 33.393333 0
# 33
