Re: [CODE] Order of Evaluation and Shorthand Problem

From: Jon A. Nielsen (nielsenja@worldspy.net)
Date: 04/14/00


> I'm having a problem with the order in which a simple expression is being
> evaluated in conjunction with a shorthand assignment operator.
>
> The relevant lines are:
>      (GET_RV(victim, DAM_GEN_INERTIA) = 50;
>      dam = 230;
>      dam *= (GET_RV(victim, DAM_GEN_INERTIA) / 100);
>
> After this line executes, dam = 0.  In actuality, it should equal 115,
since
> (by my understanding of the order of evaluation) 50 divided by 100 equals
> 1/2.  230 multiplied by 1/2 equals 115.  Yes?

My only guess would be that your variables are integers, meaning that
int(0.5) might be evaluated to be 0.  Try using a "double" variable and see
if it helps.

(e.g.:
double dam;

dam = 230.0;
dam *= double(GET_RV(victim, DAM_GEN_INERTIA) / 100);

Good luck!

___
Jon A. Nielsen
Lazarus of Spear of Insanity MUD
spear.kilnar.com:1066
http://spear.kilnar.com/


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 04/10/01 PDT