Improved float compare in certain files (AR/AP ledger)
[fa-stable.git] / includes / current_user.inc
index 7c99f233a3fbb9a1e464955ba9ae6af2ec0b77cf..51c03ee626f0e29f75fa453e756a541732a31bd8 100644 (file)
@@ -210,6 +210,20 @@ function number_format2($number, $decimals=0)
        return $decimals==='max' ? rtrim($num, '0') : $num;
 
 }
+
+/* price/float comparision helper to be used in any suspicious place for zero values? 
+usage:
+if (!floatcmp($value1, $value2)) 
+       compare value is 0
+*/
+
+define('FLOAT_COMP_DELTA', 0.0000001);
+
+function floatcmp($a, $b)
+{
+    return $a - $b > FLOAT_COMP_DELTA ? 1 : $b - $a > FLOAT_COMP_DELTA ? -1 : 0;
+}
+
 //
 //     Current ui mode.
 //