Skip to content

Commit

Permalink
Fix zero crossings for div calls
Browse files Browse the repository at this point in the history
  • Loading branch information
lochel authored and OpenModelica-Hudson committed May 12, 2017
1 parent a342dab commit d0c4de0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Compiler/Template/CodegenC.tpl
Expand Up @@ -4317,7 +4317,7 @@ template zeroCrossingTpl(Integer index1, Exp relation, Text &varDecls, Text &aux
let indx = daeExp(idx, contextZeroCross, &preExp, &varDecls, &auxFunction)
<<
<%preExp%>
gout[<%index1%>] = (trunc(<%e1%>/<%e2%>) != trunc(data->simulationInfo->mathEventsValuePre[<%indx%>]/data->simulationInfo->mathEventsValuePre[<%indx%>+1])) ? 1 : -1;
gout[<%index1%>] = (trunc((<%e1%>)/(<%e2%>)) != trunc(data->simulationInfo->mathEventsValuePre[<%indx%>]/data->simulationInfo->mathEventsValuePre[<%indx%>+1])) ? 1 : -1;
>>
else
error(sourceInfo(), ' UNKNOWN ZERO CROSSING for <%index1%>')
Expand Down
2 changes: 1 addition & 1 deletion Compiler/Template/CodegenCFunctions.tpl
Expand Up @@ -5740,7 +5740,7 @@ template daeExpCall(Exp call, Context context, Text &preExp, Text &varDecls, Tex
if acceptMetaModelicaGrammar()
then 'if (<%tvar%> == 0.0) {<%generateThrow()%>;}<%\n%>'
else 'if (<%tvar%> == 0.0) {throwStreamPrint(threadData, "Division by zero %s", "<%Util.escapeModelicaStringToCString(cstr)%>");}<%\n%>'
'trunc((<%var1%>) / <%tvar%>)'
'trunc((<%var1%>) / (<%tvar%>))'

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

0 comments on commit d0c4de0

Please sign in to comment.