Bytecraft doesn't recognize the type defs - double or float, but thank you for the advice -----Original Message----- From: Kevin Blain [mailto:kevinb@WOODANDDOUGLAS.CO.UK] Sent: Friday, February 22, 2002 10:13 AM To: PICLIST@MITVMA.MIT.EDU Subject: Re: [PIC]:MPLAB floating point in C That's why then Do somehing like Percent = (double) A / (double) B Cast K&R page 45 > -----Original Message----- > From: pic microcontroller discussion list > [mailto:PICLIST@mitvma.mit.edu] On Behalf Of Rich Mcelroy > Sent: 22 February 2002 16:30 > To: PICLIST@mitvma.mit.edu > Subject: Re: [PIC]:MPLAB floating point in C > > > 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 -- 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 ***************************************************************** This email has been checked by the altohiway e-Sweeper Service ***************************************************************** -- 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 -- 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