Quote:
|
Originally Posted by Dave Flowerday
One trick that we use frequently is to take a 16-bit number and treat the lower 8 bits as a fractional portion. That way you can stick with simple integer math operations but still obtain higher accuracy. We've done this with all of our distance calculations from wheel encoders, angle calculations from the gyro, PID controls, etc. There are always tradeoffs where using floats is justified and a decent idea. I think Dave was trying to make the point that (like any compromise) you just need to be smart about it and not make the decision without taking some time to consider the consequences.
|
That sounds like a good idea. Could you show me an example of what you mean? I don't know how you can treat the lower 8 bits as a fractional portion.
I agree with you about the tradeoffs certainly, that's why I was posting this thread before I got too deep to see if there were any alternatives and where I'll start hitting problems at if I don't. Thanks!