public void Parse(string str, int[] pars) { str = ConvertStirng(str); string tmp = InsertParValues(str, pars, false); tmp = "(" + tmp + ")"; QuestTCPVariant range = Calc(tmp); double value = range.GetValue(); value = (value < -2000000000) ? -2000000000 : value; value = (value > 2000000000) ? 2000000000 : value; try { answer = (int)Math.Round(value + +0.00000000001f); } catch { calc_error = true; error = true; answer = 0; } if ((answer < 0) && (value > 0)) { calc_error = true; error = true; answer = 0; } if (calc_error) { error = true; } }
private void OpDiv(QuestTCPVariant lf, QuestTCPVariant rf, ref QuestTCPVariant result) { result.Clear(); double l = lf.GetValue(); double r = rf.GetValue(); if (r == 0) { result.vf = (l < 0) ? -2000000000 : 2000000000; } else { result.vf = l / r; } }
private void OpIn(QuestTCPVariant lf, QuestTCPVariant rf, ref QuestTCPVariant result) { result.Clear(); if ((lf.vtype == QuestTCPVType.vtExt) && (rf.vtype == QuestTCPVType.vtExt)) { result.vf = lf.vf == rf.vf ? 1 : 0; } else if ((lf.vtype == QuestTCPVType.vtRange) && (rf.vtype == QuestTCPVType.vtExt)) { result.vf = lf.vd.Have(rf.vf) ? 1 : 0; } else if ((lf.vtype == QuestTCPVType.vtExt) && (rf.vtype == QuestTCPVType.vtRange)) { result.vf = rf.vd.Have(lf.vf) ? 1 : 0; } else if ((lf.vtype == QuestTCPVType.vtRange) && (rf.vtype == QuestTCPVType.vtRange)) { result.vf = rf.vd.Have(lf.GetValue()) ? 1 : 0; } }
private void OpMod(QuestTCPVariant lf, QuestTCPVariant rf, ref QuestTCPVariant result) { result.Clear(); double l = lf.GetValue(); double r = rf.GetValue(); r = Math.Truncate(r); if (r == 0) { result.vf = (l < 0) ? -2000000000 : 2000000000; } else { r = (r < 0) ? -r: r; bool ldz = l < 0; l = ldz ? -l : l; result.vf = Math.Truncate(l - r * Math.Truncate(l / r)); result.vf = ldz ? -result.vf : result.vf; } }
private void OpNotEq(QuestTCPVariant lf, QuestTCPVariant rf, ref QuestTCPVariant result) { result.Clear(); result.vf = lf.GetValue() != rf.GetValue() ? 1 : 0; }
private void OpMul(QuestTCPVariant lf, QuestTCPVariant rf, ref QuestTCPVariant result) { result.Clear(); result.vf = lf.GetValue() * rf.GetValue(); }