ScatterDraw: Fixed ResParallel as indicated by peterh

git-svn-id: svn://ultimatepp.org/upp/trunk@13060 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
koldo 2019-04-27 20:14:04 +00:00
parent 331bb27e3a
commit 9d149a56a4

View file

@ -497,11 +497,14 @@ public:
unit.Sqrt();
}
void ResParallel(const doubleUnit &d) {
if (val + d.val < 1e-100)
if (abs(val + d.val) < 1e-100 && abs(val*d.val) > 1e-100)
throw Exc(t_("Division by zero"));
if (!(unit.IsEqual(d.unit) || IsNull(unit) || IsNull(d.unit)))
throw Exc(t_("Units does not match in resistor parallel"));
val = val*d.val/(val + d.val);
if (abs(val*d.val) < 1e-100)
val = 0.0;
else
val = val*d.val/(val + d.val);
}
void SetNull() {val = Null;}
bool IsNullInstance() const {return IsNull(unit) && IsNull(val);}