If you are not already using floating point in your program, using it now is likely to increase your code size a lot. If you have it, maybe that is okay. But this is why C gets a "bad rap" over assembly. It is usually important to consider the result of your C statements before accepting a quick solution. I suggest "rolling your own" function in C to handle the overflow/underflow that results from integer math. David david@KosmosIsland.com On Fri, 22 Feb 2002 10:29:35 -0600 Rich Mcelroy wrote: > A is a signed long, and B is an unsigned long. two large values. > > -----Original Message----- > From: Peter Onion [mailto:ponion@SRD.BT.CO.UK] > Sent: Friday, February 22, 2002 10:04 AM > To: PICLIST@MITVMA.MIT.EDU > Subject: Re: [PIC]:MPLAB floating point in C > > > On 22-Feb-02 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. I have been getting a zero for > > percent everytime. > > What are the types of A & B please ? > > If they are integers, then the result of the division will be an integer. > > I would try > > (100.0 * A) / B > > That should "promote" the result to be a floating point type. See Page 44 > of > the Second edition of K&R. > > Peter. -- 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