> char *see_good(int current, int total) > { > int percent; > static char word[256]; > > if ((total == 200) && (current < 0)) > current = 100 - current; > > if (total < 1) > total = 1; > > percent = (current / total) * 100; > > if (percent < 1) > percent = 1; > Well it looks to me like you have everything decalared as integers percent = (current / total) * 100; Since percent, current, and total are all integers. Say you send the strength. 15 and the total 25 percent = (15 / 25) * 100 we have (integer) = (integer / integer) * integer 15 / 25 you expect to be .60 but as its an integer its 0 .60 * 100 would be 6 but you get 0 * 100 is 0 > percent = (int)( ((float)current / (float)total) * 100.0); Toss in some type casting and force evaluation to floating point if nothing else. ******************************************************************* * Ron Hensley ron@dmv.com * * Junior Systems Administrator http://www.dmv.com/~ron * * DelMarVa OnLine 749-1111 Ext. 403 * *******************************************************************
This archive was generated by hypermail 2b30 : 12/18/00 PST