Permalink
Browse files

MDL-10791 format_float() now supports non-localised output too (. dec…

…imal separator forced)
  • Loading branch information...
skodak
skodak committed Sep 27, 2007
1 parent 95aa0af commit ae8adf77c0ee3bfd0e13d42d6fb3e27916586954
Showing with 8 additions and 3 deletions.
  1. +8 −3 lib/moodlelib.php
View
@@ -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, '.', '');
+ }
}
/**

0 comments on commit ae8adf7

Please sign in to comment.