Allow `$maxDecimals = 1` for `formatDouble()`
authorAlexander Ebert <ebert@woltlab.com>
Fri, 27 Apr 2018 12:06:04 +0000 (14:06 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 27 Apr 2018 12:06:04 +0000 (14:06 +0200)
wcfsetup/install/files/lib/util/StringUtil.class.php

index 045026ea040507960b4e4f42eb20290b15016796..9f6b312df9db00e3a76fc28538100ca526a5648c 100644 (file)
@@ -198,7 +198,7 @@ final class StringUtil {
         */
        public static function formatDouble($double, $maxDecimals = 0) {
                // round
-               $double = round($double, ($maxDecimals > 2 ? $maxDecimals : 2));
+               $double = round($double, ($maxDecimals > 0 ? $maxDecimals : 2));
                
                // consider as integer, if no decimal places found
                if (!$maxDecimals && preg_match('~^(-?\d+)(?:\.(?:0*|00[0-4]\d*))?$~', $double, $match)) {