Re: [CODE] Order of Evaluation and Shorthand Problem

From: Edward J Glamkowski (eglamkowski@angelfire.com)
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);

50 / 100 = 0
Write a test program!

50.0 / 100.0, however, equal 0.5.

You need to cast your division factors into
floats:
dam *= ((float)GET_RV(victim, DAM_GEN_INERTIA) / 100.0)

Actually, it is enough to just write the 100
as 100.0, but it rarely hurts to be more
concise.



Angelfire for your free web-based e-mail. http://www.angelfire.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