Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit d0c4de0

Browse files
lochelOpenModelica-Hudson
authored andcommitted
Fix zero crossings for div calls
1 parent a342dab commit d0c4de0

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Compiler/Template/CodegenC.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4317,7 +4317,7 @@ template zeroCrossingTpl(Integer index1, Exp relation, Text &varDecls, Text &aux
43174317
let indx = daeExp(idx, contextZeroCross, &preExp, &varDecls, &auxFunction)
43184318
<<
43194319
<%preExp%>
4320-
gout[<%index1%>] = (trunc(<%e1%>/<%e2%>) != trunc(data->simulationInfo->mathEventsValuePre[<%indx%>]/data->simulationInfo->mathEventsValuePre[<%indx%>+1])) ? 1 : -1;
4320+
gout[<%index1%>] = (trunc((<%e1%>)/(<%e2%>)) != trunc(data->simulationInfo->mathEventsValuePre[<%indx%>]/data->simulationInfo->mathEventsValuePre[<%indx%>+1])) ? 1 : -1;
43214321
>>
43224322
else
43234323
error(sourceInfo(), ' UNKNOWN ZERO CROSSING for <%index1%>')

Compiler/Template/CodegenCFunctions.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5740,7 +5740,7 @@ template daeExpCall(Exp call, Context context, Text &preExp, Text &varDecls, Tex
57405740
if acceptMetaModelicaGrammar()
57415741
then 'if (<%tvar%> == 0.0) {<%generateThrow()%>;}<%\n%>'
57425742
else 'if (<%tvar%> == 0.0) {throwStreamPrint(threadData, "Division by zero %s", "<%Util.escapeModelicaStringToCString(cstr)%>");}<%\n%>'
5743-
'trunc((<%var1%>) / <%tvar%>)'
5743+
'trunc((<%var1%>) / (<%tvar%>))'
57445744

57455745
case CALL(path=IDENT(name="mod"), expLst={e1,e2}, attr=CALL_ATTR(ty = ty)) then
57465746
let var1 = daeExp(e1, context, &preExp, &varDecls, &auxFunction)

0 commit comments

Comments
 (0)