Hi Joep! > Long vars are a true advantage. However, use them as a substitute for float > does require a lot more attention:
> - you need to plan for the max used value and the min required accuracy. This is true. But in many cases this shouldn't be too hard. If you're dealing with time, probably a femtosecond is precise enough. If it is length, it's probably a micrometer. If you really don't know beforehand, you can use a 83-byte variable multiplied by 10^100, this is what a common pocket calculator can display. maximum range 10^100, resolution 10^-100. (I might be wrong here, I'm not sure the compiler can handle multiplications and divisions on this size.) > - you need to manual track the fixed point position of a variable and correct > it at each multiply/divide >- if you have vars with different fixed point settings, you need to correct >for this before add/ subtract. True. I had in mind a fixed setting for all fixed point variables within a project, then a library could do multiplications and divisions. Add/subtract would be just like a=b+c. Constants have to be looked after, though... > - assing and print properly is not as obvious as real floats. Very true ;-) Assigning a constant value which is not zero is nearly impossible. But a function could be implemented to do this: pi=fixpoint_divide(fixpoint_int_to_fix(314159),fixpoint_int_to_fix(100000)) Printing has to be done through a library function, just like for integers. > It might be possible to implement floats in a library and use a large > variable ( or struct?) to store it and pass it to functions. Most of such a > library would be straightforward. The main issue would be to maintain the > optimal exponent. I had preferred fixed point, because at least add/subtract would be no effort, and printing is really easy, too. But it's worth to think in this direction, too, of course. My math skills are a bit rusty in this field, though ;-) > Print_string(serial_hw_data, 'hello JAL world.') would be a start. It is a > personal feature request from the moment strings were introduced but has not > been implemented in all those years. This points in the direction where the cause might be lying why I prefer to think about a fixed point lib and not asking for compiler support of float vars ;-) And, switching to C is not an option for me right now... I dislike C so much that I would take quite an effort to avoid using it... Greets, Kiste -- You received this message because you are subscribed to the Google Groups "jallib" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/jallib?hl=en.
