Scott Dattalo wrote: > > nogueira wrote: > > > > I'd like to get help solving this: > > > > TEMPERATURE=TEMP_READ-0.25+(COUNT_PER_C-COUNT_REMAIN)/COUNT_PER_C > > > > where: > > TEMP_READ = 8 bits > > COUNT_PER_C = 8 bits > > COUNT_REMAIN = 8 bits > > TEMPERATURE = 8 bits > > > > I just want a small routine to do this math. > > It's about time somebody asked another PIC related math question! > > Suppose you make this little simplification: > > TEMPERATURE=TEMP_READ-0.25+(COUNT_PER_C-COUNT_REMAIN)/COUNT_PER_C > =TEMP_READ-0.25+ 1 - COUNT_REMAIN/COUNT_PER_C > =TEMP_READ+0.75 - COUNT_REMAIN/COUNT_PER_C > > Now, for an assumption/question. I assume that "TEMP_READ" is an 8-bit > integer that is very close to the correct temperature. The rest of the > equation is the fractional portion of "TEMPERATURE". Or maybe it is at > most one or two counts. Are these assumptions true? > If so, there are two tricks I can think of that can efficiently "solve" > this equation. But rather than posting a solution without first knowing > the problem, I'll wait to you verify the assumptions. > > Scott Yes, you are absolutely right. Octavio -- ======================================================== Octavio Nogueira e-mail: nogueira@mandic.com.br homepage: http://ourworld.compuserve.com/homepages/tato voice/fax: +55 11 240-6474 ======================================================== "ProPic" The first Production PIC Programmer running in Windows and under US$ 20.00. Avaible at http://ourworld.compuserve.com/homepages/tato