I just checked on our branch and there it is zero (i.e. in MathModelica it is currently zero). This a type conversion feature/bug. The expression 8 * 10^-5 is actually an integer expression, 8 * 1/10000, which is then type converted at the top level to a Real, which gives 0.0;
This is somewhat bad in the specification. It reads: " Exponentiation "a^b" is defined as pow(double a,double b) in the ANSI C library if both "a" and "b" are Real scalars. A Real scalar value is returned. If "a" or "b" are Integer scalars, they are automatically promoted to "Real"." However, Dymola (v7.4) gives the following: a:=2^3 Declaring variable: Integer a ; b:=2^(-3) Declaring variable: Real b ; That is, they do not follow the specification, instead they declare a Real if the value is negative! What if you want to do integer arithmetic's like 3 +6*2^(-3) ? Dymola does: c:=3 +6*2^(-3) Declaring variable: Real c ; Which is wrong. It should be 15/4 If you however write c:=3 +16*2^(-3) Declaring variable: Integer c ; IMO this is really bad! /Peter > -----Original Message----- > From: [email protected] [mailto:owner- > [email protected]] On Behalf Of Martin Sjölund > Sent: den 30 maj 2011 10:46 > To: [email protected] > Cc: Christoph Höger > Subject: Re: Strange bug > > Hi, > > I don't see any problem with the code running in OpenModelica... > > loadString(" > model Test > Real x; > parameter Real p = 8 * 10^(-5); //becomes 0? > > equation > x = time * p; > end Test; > "); > simulate(Test); > val(x,0:0.1:1); > > => > > {0.0,8e-06,1.6e-05,2.4e-05,3.2e-05,4e-05,4.8e-05,5.6e-05,6.4e-05,7.2e-05,8e- > 05} > > -- > Martin Sjölund > > On 2011-05-30 09:49, Christoph Höger wrote: > > Hi, > > > > what is wrong with that? > > > > model Test > > Real x; > > parameter Real p = 8 * 10^(-5); //becomes 0? > > > > equation > > x = time * p; > > end Test; > > > > best, > > > > Christoph > >
