]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-10791 format_float() now supports non-localised output too (. decimal separator...
authorskodak <skodak>
Thu, 27 Sep 2007 09:58:40 +0000 (09:58 +0000)
committerskodak <skodak>
Thu, 27 Sep 2007 09:58:40 +0000 (09:58 +0000)
lib/moodlelib.php

index 1538aca13e4a2f058eb20d213ebad47486080846..68dfba0cc50e9f777a2e41d9759ed76535891525 100644 (file)
@@ -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, '.', '');
+    }
 }
 
 /**