From: Ryan B. <rya...@ya...> - 2004-07-28 07:31:44
|
I've had difficulties with the floating point library as well. Besides its enormous size, I've noticed incorrect results when tested with random numbers (using a PC as reference). I've cobbled together a limited (non-optimized) floating point library in assembly. I tried to make it correct and reasonably small. It takes less than 1K of code and works only on the mcs51 in small model. It has a limited notion of infinity to avoid overflow randomness. It overrides the default __fsadd() __fssub() __fsmul() and various type conversion routines such as __uchar2fs(). It does not have __fsdiv() support. The transcendental functions (sin cos sqrt etc) are not implemented. These functions do a lot of adding and multiplying though, so using this library may help a bit. The overall size would probably still be large enough to exclude small model, in which case this is of no help. (Well maybe not -- I don't know about other models) I may also be doing some non-standard stuff with regards to rounding. I round the LSB up if the next-lower bit is 1 (instead of truncating). This happens even when converting a float to a long, so { long x = __fstoslong (-2.5); } would set x to -3; Ryan __________________________________ Do you Yahoo!? Yahoo! Mail - 50x more storage than other providers! http://promotions.yahoo.com/new_mail |