Michael Mullen wrote: > Having some experience with precision instruments with floating point > displays, I point out that I have never, in fact, found it necessary > to actually do the calculations in floating point. I usually scale > until I can do a fixed point operation, or operate with a scale > factor. Thanks for your reply to my query, Michael. My original posting described a situation where fixed point calculations were not suitable because the translation equations (and therefore the numeric ranges) weren't known in advance. I'm working on a project at the moment where user-replaceable sensors are plugged into a base unit; each sensor having a 40-byte EEPROM (Dallas 24A30) containing the sensor name (ie, LCD text string) and calibration constants, etc. The main controller is not a PIC, but only because of the lack of floating point support in the programming tools. > In contrast, the constants given in Doug Manzer's tangent calculation > are 9 decimal digits. If this were used to measure angles in a > navigation system, one could measure one's longitude anywhere on the > earth to to a precision of less than 2 inches. For most problems, > this level of precision is overkill. Agreed, although some guard digits are necessary. A 12-bit a/d converter will return a result in the range 0 to 4095, ie. 4 decimal digits so perhaps 5 or 6 digit precision would be reasonable in calculations. > I don't mean to be dogmatic; there _ARE_ valid reasons for FP and > high precision operations. However, I would suggest strongly that, if > you really need such things, you might consider a more powerful > processor (or, more accurately, one with more powerful tools). ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This is my whole point; there are compilers with the float data type for the HC11, which has roughly the same computing power as the higher-end PIC's so the problem with with the tools. Since this IS a PIC forum I was hoping to find a PIC-based solution. I can see three main phases in a f/p computation: 1.a Convert the acquired value (typically binary integer) to f/p in whatever radix is used internally 1.b It may also be necessary to accept input in decimal format from the user (eg. for calibration constants) which need to be translated into f/p format. 2. Perform the f/p operations 3. Convert the result to readable form in decimal format AND575 in Microchip's _Embedded Control Handbook_ provides only partial solutions for these operations. Phase 1.a at least is covered with an integer to float conversion. Relevant to Phase 1.b, it includes a floating point to binary conversion algorithm for which the first step is... z = ln A / ln 2 ...however, the author doesn't include an ln() function in his math library. For Phase 2, AN575 covers only the 4 basic math functions with no mention of transcendental functions. Phase 3 is also awkward, as the library functions produce results in Microchip's modified IEEE754 format. There is a float to integer conversion, but only with a limited range. I would like to see an equivalent to Borland's fcvt(), described in their _C++ Library Reference_ as follows (with capitals in place of italics): ----------------------------------------------------- Function Converts a floating-point number to a string. Syntax #include char *fcvt(double VALUE,int NDIG,int*DEC,int *SIGN) ; Remarks fcvt converts VALUE to null-terminated string digits, starting with the leftmost significant digit, with NDIG digits to the right of the decimal point. fcvt then returns a pointer to the string. The position of the decimal point relative to the beginning of the string is stored indirectly through DEC (a negative value for DEC means to the left of the returned digits). There is no decimal point in the string itself. If the sign of value is negative, the word pointed to by SIGN is nonzero; othersie, it is 0. The correct digit has been rounded for the number of digits to the right of the decimal point specified by NDIG. Ret val The return value of fcvt points to static data whose content is overwritten by each call to fcvt and ecvt. See also ecvt, gcvt, sprintf ----------------------------------------------------- An ascii string with sign and exponent information could be used to derive the message string for the readout, typically a 7-segment display with format 8.8.8.8 or an LCD. Regards, Doug Manzer ps. thanks to everyone who emailed help and suggestions; I will reply shortly.