EA31337 / EA31337-classes

📦📈 EA31337 framework (MQL library for writing trading Expert Advisors, indicators and scripts)
https://ea31337.github.io/EA31337-classes
GNU General Public License v3.0
190 stars 100 forks source link

Zero divide, check divider to avoid this error in 'Math.h' (81,22) #648

Open kenorb opened 2 years ago

kenorb commented 2 years ago

2014.10.31 06:00:00: zero divide, check divider to avoid this error in 'Math.h' (81,22)

  static double ChangeInPct(double _v1, double _v2, bool _hundreds = false) {
    double _result = 0;
    if (_v1 != 0 && _v2 != 0) {
      // If values are non-zero, use the standard formula.
      _result = (_v2 / _v1) - 1;
kenorb commented 1 year ago

Could be compilation MTE bug (older version), since condition clearly states when _v1 and _v2 is not zero, but the exception still happens. I've compiled the same code in the latest MT5, the error doesn't seems to happen.