Procházet zdrojové kódy

round公用四舍五入去除

xialei před 1 rokem
rodič
revize
1671b163c8
1 změnil soubory, kde provedl 18 přidání a 0 odebrání
  1. 18 0
      app/common.php

+ 18 - 0
app/common.php

@@ -897,3 +897,21 @@ if (!function_exists("is_json")){
897
         return true;
897
         return true;
898
     }
898
     }
899
 }
899
 }
900
+
901
+
902
+
903
+if (!function_exists("roundOptimize")){
904
+    /**
905
+     * round公用四舍五入去除
906
+     * @param $number
907
+     * @return string
908
+     */
909
+    function roundOptimize($amount, $decimals = 2): string
910
+    {
911
+        if ($amount > 0) {
912
+            $factor = pow(10, $decimals);
913
+            return floor($amount * $factor) / $factor;
914
+        }
915
+        return $amount;
916
+    }
917
+}