Opened 16 years ago

Last modified 16 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, adrpo

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)

main.mo (1.6 KB) - added by yadaniel 16 years ago.

Download all attachments as: .zip

Change History (3)

Changed 16 years ago by yadaniel

comment:1 Changed 16 years ago by adrpo

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/

comment:2 Changed 16 years ago by adrpo

This is not a bug. Check the Modelica Specification. Comparison between
reals using == or <> is discouraged.

Note: See TracTickets for help on using tickets.