From: skodak Date: Thu, 27 Sep 2007 09:58:40 +0000 (+0000) Subject: MDL-10791 format_float() now supports non-localised output too (. decimal separator... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=ae8adf77c0ee3bfd0e13d42d6fb3e27916586954;p=moodle.git MDL-10791 format_float() now supports non-localised output too (. decimal separator forced) --- diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 1538aca13e..68dfba0cc5 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -6046,17 +6046,22 @@ function generate_password($maxlen=10) { /** * Given a float, prints it nicely. - * Do NOT use the result in any calculation later! + * Localized floats must not be used in calculations! * * @param float $flaot The float to print * @param int $places The number of decimal places to print. + * @param bool $localized use localized decimal separator * @return string locale float */ -function format_float($float, $decimalpoints=1) { +function format_float($float, $decimalpoints=1, $localized=true) { if (is_null($float)) { return ''; } - return number_format($float, $decimalpoints, get_string('decsep'), ''); + if ($localized) { + return number_format($float, $decimalpoints, get_string('decsep'), ''); + } else { + return number_format($float, $decimalpoints, '.', ''); + } } /**