You can either use a higher precision or the following code fragment to calculate the percentage of ul1 of ul2. The following code fragment requires only 16 bit ints. The For loop creates a variable p that is a binary fraction of ul1/ul2 The format of p is essentially a fixed point number of the form i.f where each i (integer) and f (fraction) are 8 bits. Multiply p by 100 will give a percentage. (add 0x80 to roundoff the percentage) Shift the result by 8 bits will normalize the result to an intereger value from a fixed point value. Walter Banks { unsigned int16 x,ul1,ul2; ul1 = 4500; ul2 = 10000; unsigned int16 n,p,percent; x = ul1; p = 0; for (n = 8;n != 0; n--) { x <<= 1; p <<= 1; if (x > ul2) { x -= ul2; p++; } } percent = p * 100; percent >>= 8; } Rich Mcelroy wrote: > > I'm using Bytecraft's compiler for MPLAB. it does basic math, but the > results I'm getting indicate that it is droping anything after the integer > on my calculations. I'm trying to calculate a percentage: > > Percent = A/B * 100; something like that. -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics