Fixed numeric format issue
authorMarcel Werk <burntime@woltlab.com>
Thu, 17 Jul 2014 13:29:39 +0000 (15:29 +0200)
committerMarcel Werk <burntime@woltlab.com>
Thu, 17 Jul 2014 13:29:39 +0000 (15:29 +0200)
wcfsetup/install/files/lib/util/StringUtil.class.php

index a51a41fa88a8b927a39d8629053eece52ae8b300..6466b60742cbc6fe2c545f3c57fdc7a9108b238c 100644 (file)
@@ -190,14 +190,14 @@ final class StringUtil {
         * @return      string
         */
        public static function formatDouble($double, $maxDecimals = 0) {
+               // round
+               $double = round($double, ($maxDecimals > 2 ? $maxDecimals : 2));
+               
                // consider as integer, if no decimal places found
                if (!$maxDecimals && preg_match('~^(-?\d+)(?:\.(?:0*|00[0-4]\d*))?$~', $double, $match)) {
                        return self::formatInteger($match[1]);
                }
-               
-               // round
-               $double = round($double, ($maxDecimals > 2 ? $maxDecimals : 2));
-               
+                               
                // remove last 0
                if ($maxDecimals < 2 && substr($double, -1) == '0') $double = substr($double, 0, -1);