On Fri, 20 Dec 1996, Niese-Petersen wrote: > That should be: > #define FIELD(x) ((x) < 32 ? 0 : (x) / 32) > if you want it right [A 4 space array goes from 0 to 3] > But then again, if you do this: > #define FIELD(x) (int) ((x) / 32) > then (x < 32) / 32 will always be 0, which was I had in mind first time. Ooops, you're right. That was a stupid mistake... :) > > > #define BIT(x) ((x) < 32 ? (x) : (x) % 32) > Of coz this works, but (x < 32) MOD 32) will always be x [% is MOD, > or the rest of x / 32) Funny, I must be using new math, because the remainder of (x/32) wasn't (x) by my calculations. Perhaps that's a quirk of the mod operator that I'm not aware of? > Dont know what you use of compiler, but in my books % always give the rest > of a division. Or is my brain totally dead ? [I have been away from MUD > coding for a few months now :/ ] It gives the remainder of a division, you're right. I don't, though, see your point here... -- Daniel Koepke dkoepke@california.com Forgive me father, for I am sin. +-----------------------------------------------------------+ | 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/18/00 PST