Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

…imal separator forced)
  • Loading branch information...
commit ae8adf77c0ee3bfd0e13d42d6fb3e27916586954 1 parent 95aa0af
authored September 27, 2007

Showing 1 changed file with 8 additions and 3 deletions. Show diff stats Hide diff stats

  1. 11  lib/moodlelib.php
11  lib/moodlelib.php
@@ -6046,17 +6046,22 @@ function generate_password($maxlen=10) {
6046 6046
 
6047 6047
 /**
6048 6048
  * Given a float, prints it nicely.
6049  
- * Do NOT use the result in any calculation later!
  6049
+ * Localized floats must not be used in calculations!
6050 6050
  *
6051 6051
  * @param float $flaot The float to print
6052 6052
  * @param int $places The number of decimal places to print.
  6053
+ * @param bool $localized use localized decimal separator
6053 6054
  * @return string locale float
6054 6055
  */
6055  
-function format_float($float, $decimalpoints=1) {
  6056
+function format_float($float, $decimalpoints=1, $localized=true) {
6056 6057
     if (is_null($float)) {
6057 6058
         return '';
6058 6059
     }
6059  
-    return number_format($float, $decimalpoints, get_string('decsep'), '');
  6060
+    if ($localized) {
  6061
+        return number_format($float, $decimalpoints, get_string('decsep'), '');
  6062
+    } else {
  6063
+        return number_format($float, $decimalpoints, '.', '');
  6064
+    }
6060 6065
 }
6061 6066
 
6062 6067
 /**

0 notes on commit ae8adf7

Please sign in to comment.
Something went wrong with that request. Please try again.