hartmannathan commented on PR #17363:
URL: https://github.com/apache/nuttx/pull/17363#issuecomment-3577274946

   > Regarding the floating point problem, when calculations are not important, 
for representation only two integers can be used one for integral and other for 
decimal (i.e. X.Y)? Also depending on the underlying hardware I heard that 
double may be faster than floating point especially when emulated? Is float 
type required by uORB or you mean just "floating point" as either float or 
double or two integers can be used? I did not play with uORB yet sorry :-P
   
   Regarding single-precision float vs double-precision double vs fixed-point 
of various types:
   
   Performance (speed) really depends on the platform. A microcontroller that 
has hardware 32-bit (single-precision) float but not hardware 64-bit 
(double-precision) will probably calculate single-precision much faster than 
double-precision, because the double would be emulated in software.
   
   I think what you're talking about (double being faster) might have something 
to do with C's argument promotion rules, where a float variable would be 
implicitly converted to double when calling functions, leading to more code and 
slower execution for float.
   
   Another issue to pay attention to is that double does not always mean 
double. Sometimes (depending on compiler options and the provided math library) 
double is actually single. That is, you write double in the code and it 
silently becomes single in reality. That can take you by surprise if you're not 
aware of it.
   
   Yet another issue to be aware of is that not all floating point units are 
IEEE754 compliant and floating point implementations (hardware and software) 
can differ in their precision. I've been bitten by this before.
   
   Fixed point comes in many different varieties: you have to choose the range 
of the whole and fraction parts according to how you'll use the variable but 
the advantage is that between any two consecutive numbers the fractional 
resolution is consistent.
   
   I don't know whether any of our supported archs have fixed point 
implementations in hardware.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to