Selaa lähdekoodia

round公用四舍五入去除

xialei 1 vuosi sitten
vanhempi
commit
1671b163c8
1 muutettua tiedostoa jossa 18 lisäystä ja 0 poistoa
  1. 18 0
      app/common.php

+ 18 - 0
app/common.php

@@ -897,3 +897,21 @@ if (!function_exists("is_json")){
897 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
+}