From 8cac64c1cbef2b3a55bb539ffbb429ff1f58939a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org> Date: Fri, 7 Oct 2022 17:51:10 +0200 Subject: [PATCH] use_dll: fix bug where operator abs() within a .mod file would return an incorrect result MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It would compute the *integer* part of the absolute value (calling “abs” instead of “fabs” from the C source). --- src/ExprNode.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ExprNode.cc b/src/ExprNode.cc index 3159204b..f2d585b8 100644 --- a/src/ExprNode.cc +++ b/src/ExprNode.cc @@ -2824,7 +2824,10 @@ UnaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type, output << "cbrt"; break; case UnaryOpcode::abs: - output << "abs"; + if (isCOutput(output_type)) + output << "fabs"; + else + output << "abs"; break; case UnaryOpcode::sign: if (output_type == ExprNodeOutputType::CDynamicModel || output_type == ExprNodeOutputType::CStaticModel) -- GitLab