Quote:
Originally Posted by davidthefat
Okay, I was wondering if anyone has any idea why the WPILib uses doubles instead of floats. It makes more sense to me to use floats over doubles. I find it very "costly" to use 32 extra bits. Also, why are variables like PWM ints? Why not a short? Sure, if java had unsigned variables, I would have used uint_8 (unsigned byte) instead.
Now, keep in mind, this is an embedded system. It is not a good idea to spam usage of doubles IMHO. Even if we have like 64 mb of ram. I know, you can fill that up with over 6 million doubles, but it still bothers me.
|
I spent several years cramming fairly sophisticated signal processing and pattern matching algorithms onto embedded systems, and one of the lessons I took from the experience is that the embedded world doesn't always work the way one would naively expect.
While integer arithmatic was always preferable for speed we encountered several situations where floating point calculation was faster using double precision than single precision floats due to implementation details in support libraries. And in almost all cases of consumer electronics memory access speed was a more significant practical constraint that raw number crunching.
IMHO the primary purpose of the library is clarity and utility for programmers of various abilities. Bit cramming efficiency should be at best a secondary consideration.