﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
3782	Wrong floor of integer	Rüdiger Franke	Lennart Ochel	"The backend replaces `mod` with `floor`, ignoring that the former exists for integer and real, while the latter only exists for real. See Modelica spec and other programming languages, like C++ std::floor.

See the following example:
{{{#!mo
model IntegerModulusTest
  input Integer x = 5;
  Integer y = 3;
  Integer m = mod(x, y);
end IntegerModulusTest;
}}}

Translation with `setCommandLineOptions(""+d=dumpTransformedModelica"")` gives:
{{{#!mo
/* This is probably not complete. */
model IntegerModulusTest
  /* system #1 */
  Integer m();
equation
  /* system #1 */
  m = x - floor(x / 3, 0) * 3;
end IntegerModulusTest;
}}}
This causes a cast error with `clang` if used in array initializers (`gcc` issues a warning):
   error: type 'double' cannot be narrowed to 'int' in initializer list
The C++ runtime translates Modelica floor to std::floor -- both languages define it only for real.

See:
https://test.openmodelica.org/libraries/PowerSystems_cpp/files/PowerSystems.Examples.Spot.AC3ph.Sensor.err

The problem could be worked around in the code generation. But it should be solved at the root cause. The backend must not introduce `floor` for integers. Either leave `mod` (like in the initial system for this example) or replace `floor(x / 3, 0)` with `(x / 3)`."	defect	closed	high		Backend		fixed		Willi Braun
