>
>>should it be: (int)(GET_LVL(ch) / 10) + 1;
>>or should it be:(int)(GET_LVL(ch)) / 10 + 1;
>
>wouldn't these produce the same result? I am not sure but i think C follows
>most of the same rules as arithmetic (mult and div then add and sub).
>correct me if i'm wrong and i'm sure you will.
You're wrong, Parenthesis come before any of that.
IE It would evaluate GET_LEVEL(ch) as an INTEGER before continuing.
say the level is 69 (nice number eh?)
first example would result in 69/10 = 6.9
If 6.9 is evaluated as an INT, i think C completely removes the
decimal part (.9) instead of rounding up/down. so it would = 6
#1 would evaluate to 7
the second one evaluates 69 as an INT (i think they store Floats as .00001
less than the actual number) anyway, this would end up being something
screwy, because 69/10 = 6.9; then +1
and you get 7.9. and if it's not added/divided anywhere else
within the statement (or evaluated as an INT) then it would round up
(i think) to 8
so #1 evaluates to 7
and #2 evaluates to 8
I think that's a small (yet FAIRLY IMPORTANT) difference.
Feel free to correct me if i'm wrong on how C handles integers.
code on
Akuma the Raging Coder
+------------------------------------------------------------+
| "The poets talk about love, but what I talk about is DOOM, |
| because in the end, DOOM is all that counts." - |
| Alex Machine/George Stark/Stephen King, The Dark Half |
| "Nothing is IMPOSSIBLE, Just IMPROBABLE" |
| "Easier Said Than Done, But Better Done Than Said..." |
+------------------------------------------------------------+
+-----------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
| http://cspo.queensu.ca/~fletcher/Circle/list-faq.html |
+-----------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/08/00 PST