# 
# Bash source file for percent computing
#
# (C) 2011-2012 Felix Hauri - felix@f-hauri.ch
# Licensed under terms of LGPL v3. www.gnu.org

# after sourcing script:
# syntaxe: percent <amount> <total> [varname]

percent() {
    local p=000$((${1}00000/$2))
    printf ${3+-v} $3 "%.2f%%\n" ${p:0:${#p}-3}.${p:${#p}-3}
}

export -f percent
