Skip to content

Commit

Permalink
Guard against divisions by zero
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@18729 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Jan 22, 2014
1 parent a16f990 commit 29bbd28
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Compiler/FrontEnd/ModelicaBuiltin.mo
Expand Up @@ -2861,7 +2861,7 @@ function getSimulationOptions
output Real startTime;
output Real stopTime;
output Real tolerance;
output Real numberOfIntervals;
output Integer numberOfIntervals;
output Real interval;
external "builtin";
annotation(Documentation(info="<html>
Expand Down
2 changes: 1 addition & 1 deletion Compiler/Script/CevalScript.mo
Expand Up @@ -2344,7 +2344,7 @@ algorithm
tolerance = ValuesUtil.valueReal(Util.makeValueOrDefault(Ceval.cevalSimple,toleranceExp,Values.REAL(tolerance)));
Values.INTEGER(numberOfIntervals) = Util.makeValueOrDefault(Ceval.cevalSimple,intervalExp,Values.INTEGER(numberOfIntervals)); // number of intervals
interval = Util.if_(numberOfIntervals == 0, interval, realDiv(realSub(stopTime,startTime),intReal(intMax(numberOfIntervals,1))));
numberOfIntervals = Util.if_(numberOfIntervals == 0, realInt(realCeil(realDiv(realSub(stopTime,startTime),interval))), numberOfIntervals);
numberOfIntervals = Util.if_(numberOfIntervals == 0, Util.if_(realGt(interval,0.0),realInt(realCeil(realDiv(realSub(stopTime,startTime),realMax(interval,1e-300 /* TODO: Use real if-expressions to skip these things */)))),0), numberOfIntervals);
then
(cache,Values.TUPLE({Values.REAL(startTime),Values.REAL(stopTime),Values.REAL(tolerance),Values.INTEGER(numberOfIntervals),Values.REAL(interval)}),st);

Expand Down

0 comments on commit 29bbd28

Please sign in to comment.