Re: [CODE] Order of Evaluation and Shorthand Problem

From: Axiem (axiem@swbell.net)
Date: 04/14/00


> 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?
>

Dam is declared as an integer, right? For integers, 50/100 == 0. What
you need to do is do this:
dam *= GET_RV(victim, DAM_GEN_INERTIA);
dam /= 100;

this will get:
230 * 50 == 11500
11500 / 100 == 115

If you want to multiply integers by floats, you have to do stuff with
powers of 10 :)

-Axiem
-axiem@swbell.net
-AIM: Axiem


     +------------------------------------------------------------+
     | 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