On Mon, 9 Mar 1998 10:56:06 -0800, you wrote: >Hello, > >Does anyone have a simple way of converting from degrees Celsius >to degrees Fahrenheit (and vice-versa) using PIC math? > >C -> F >====== >C*9/5 + 32 > > >F -> C >====== >(F-32)(5/9) > > >Thanks in advance! > >-Randie >rohtsji@glenayre.com A technique I used a while ago to simplify the maths when displaying a temperature value derived from a lookup table (for a thermistor) was to make the table entries equal to (deg.C * 4/5)+32 (lookup table calculated from thermistor curve). To display C you do (entry-32) * 5 >> 2 To display F you do ((entry-32) * 9 >>2) +32 This handles negative values (remember to propagate sign in the maths!), and the *5 and *9 multiply ops can each be done with shifts and an add. It is also very amenable to using the same code with a couple of conditional skips to select C or F . ____ ____ _/ L_/ Mike Harrison / White Wing Logic / wwl@netcomuk.co.uk _/ L_/ _/ W_/ Hardware & Software design / PCB Design / Consultancy _/ W_/ /_W_/ Industrial / Computer Peripherals / Hazardous Area /_W_/