Opened 17 years ago
Last modified 17 years ago
#1011 closed defect (invalid)
in algorithm section if x == 0.0 then doesnt compile
Reported by: | yadaniel | Owned by: | yadaniel |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | Version: | 1.4.5 | |
Keywords: | Cc: | yadaniel, Adrian Pop |
Description
{{{if x >= 1 and x<=1 then BUG, == should compile here
x:=0; x := -1*computeAdder(x=3, y=x);
end if;
if (x > 10) then
x := 1;
else
x := x + 1;
end if;}}}
Attachments (1)
Change History (3)
by , 17 years ago
comment:1 by , 17 years ago
comment:2 by , 17 years ago
This is not a bug. Check the Modelica Specification. Comparison between
reals using == or <> is discouraged.
Note:
See TracTickets
for help on using tickets.
Is this algorithm section in a function or in a model?
Check the Modelica specification why the
or <> comparison between reals discouraged:
\\|http://www.modelica.org/documents/ModelicaSpec30.pdf
Section 3.5, Page 18, bullet 5.
In relations of the form v1 == v2 or v1 <> v2, v1 or v2 shall, unless used in a function, not be a subtype of Real.
The reason for this rule is that relations with Real arguments are transformed to state events (see Events, Section 8.5) and this transformation becomes unnecessarily complicated for the == and <> relational operators (e.g. two crossing functions instead of one crossing function needed, epsilon strategy needed even at event instants). Furthermore, testing on equality of Real variables is questionable on machines where the number length in registers is different to number length in main memory.
Cheers,
Adrian Pop/