From be977a75d7b3fd55843d19cfffa79f4f13be5f47 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Sat, 16 Jul 2005 21:59:53 +0000 Subject: [PATCH] * Added a percent() function --- includes/GlobalFunctions.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 07e7750c0d..c0c9e0abaf 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -1276,4 +1276,14 @@ function wfIncrStats( $key ) { } } +/** + * @param mixed $nr The number to format + * @param int $acc The number of digits after the decimal point, default 2 + * @param bool $round Whether or not to round the value, default true + * @return float + */ +function percent( $nr, $acc = 2, $round = true ) { + $ret = sprintf( "%.${acc}f", $nr ); + return $round ? round( $ret, $acc ) . '%' : "$ret%"; +} ?> -- 2.20.1