On Sat, 8 Feb 1997, Mark Crichton wrote: > > From: Daniel Koepke <dkoepke@california.com> > > > > On Fri, 7 Feb 1997, Brian Williams - Nashak wrote: > > > > > question... would > > > int percent = (GET_HIT(victim) / dam) * 100; > > > always return 100? > > > I want it so that it'll go into decimals for the division, and then > > > * 100 would be the percent of hp you do in damage.. thanks for > > > a response =) > > > > Integers in C don't permit decimals. So: > > > > (25 / 2) * 100 > > > > Will equal (12.5) * 100, and finally 1200. That's probably not the > > desired result, no? > > Now, if he wants to do decimals for the division, 25 / 2 will return an int, > but: > > (int) percent = ( (float) GET_HIT(victim) / (float) dam) * 100.0; Someone earlier stated percent = (dam * 100) / GET_HIT(victim); and it works fine =) > > Should do what he wants, although I don't know how much stuff will get lost in > all the casting (IMHO, it's an ugly way to do it...) Any math experts out > there come up with a better way and keep it all int based? > > Mark > +-----------------------------------------------------------+ > | Ensure that you have read the CircleMUD Mailing List FAQ: | > | http://cspo.queensu.ca/~fletcher/Circle/list_faq.html | > +-----------------------------------------------------------+ > /---------\ /--------/ / /XXXXXXX\ \ / ////// / / ///XXXXX\\\ \ / ////// / / /////XXX\\\\\ \/ ////// / -=-=-=-=-=-=-=- / ////// \\\\\\\ ////// / Brian Williams / ////// /\ \\\\\XXX///// / bmw@efn.org / ////// / \ \\\XXXXX/// / / ////// / \ \XXXXXXX/ / /\ /_ |_| /\ |/ /--------/ \---------/ /--\ / | | /--\ |\ +-----------------------------------------------------------+ | 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