C How to calculate a percentage(perthousands) without floating point precision
问题 How do you calculate a percentage from 2 int values into a int value that represents a percentage(perthousands for more accuracy)? Background/purpose: using a processor that doesn't have a FPU, floating point computations take 100's of times longer. int x = 25; int y = 75; int resultPercentage; // desire is 250 which would mean 25.0 percent resultPercentage = (x/(x+y))*1000; // used 1000 instead of 100 for accuracy printf("Result= "); printf(resultPercentage); output: Result= 0 When really