Re: newbie C question

From: Allen Gould (agould@GPU.SRV.UALBERTA.CA)
Date: 07/13/97


On Sun, 13 Jul 1997, Justin wrote:

> Really simple and quick question here.  I'm type-casting and using defines
> to get my number.  How should the ()'s be placed?  Here's an example of
> what I'm doing:
> should it be:   (int)(GET_LVL(ch) / 10) + 1;
> or should it be:(int)(GET_LVL(ch)) / 10 + 1;

Remember that the you will turn whatever is in the ()s into an int.
I'd suggest using (int)(GET_LEL(ch) / 10) + 1, since it guarantees that
you'll be adding 1 to an integer. But I think either would work, since
division with integers still leaves an integer.

> sorry for such a simple question.

Don't sweat it - I'm thrilled to be able to answer :)

--
Allen Gould - agould@gpu.srv.ualberta.ca
Asst. Editor, Delirium Magazine - http://www.talkroom.com/~delirium/
In alt.starfleet.rpg - Lt. (j.g.) Phoenix, USS TRAFALGAR
You can make it foolproof, but you can't make it damn-fool proof.


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