Just to point out, you can get floating point wrapped up in a chip: http://www.al-williams.com/awce/pak1.htm. Also, if you do use the Microchip routines, drop by our site and pick up our Windows float/ieee/microchip float conversion program -- a free download. http://www.al-williams.com/awce (look for Fconvert towards the bottom). Good luck! Al Williams AWC * Easy RS-232 Prototyping http://www.al-williams.com/awce/rs1.htm > -----Original Message----- > From: pic microcontroller discussion list > [mailto:PICLIST@MITVMA.MIT.EDU] On Behalf Of Rich Mcelroy > Sent: Friday, February 22, 2002 11:06 AM > To: PICLIST@MITVMA.MIT.EDU > Subject: Re: [PIC]:MPLAB floating point in C > > > Dale, > > that would be great, and I actually tried to do that first, > but Bytecraft doesn't recognize "float" as a type def. Do > you know of a compiler for MPLAB that does? > > Richard > > -----Original Message----- > From: Dale Botkin [mailto:dale@BOTKIN.ORG] > Sent: Friday, February 22, 2002 10:40 AM > To: PICLIST@MITVMA.MIT.EDU > Subject: Re: [PIC]:MPLAB floating point in C > > > On Fri, 22 Feb 2002, Rich Mcelroy wrote: > > > A is a signed long, and B is an unsigned long. two large values. > > That's probably the problem. Dunno about Bytecraft, but the > compiler probably isn't quite intiutive enough to know that > you want to perform an operation with two longs and get a > float result. It's probably going to do a long mult, then > try to map the result into a float variable... the results > aren't going to be pretty, I've found. > > Try this: > > float Percent; > signed long A; > unsigned long B; > > Percent = (float)A/(float)B; > Percent *= 100; > > You may want to take a look at the resulting code size. I > find my compiler often generates much smaller, cleaner code > with something like > this: > > float Percent, fA, fB; > signed long A; > unsigned long B; > > fA = (float)A; > fB = (float)B; > Percent = fA/fB; > Percent *= 100; > > Dale > -- > "Curiosity is the very basis of education and if you tell me > that curiosity killed the cat, I say only the cat died nobly." > - Arnold Edinborough > > -- > 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 -- 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