MAX6675-library icon indicating copy to clipboard operation
MAX6675-library copied to clipboard

change implicit conversions to floats

Open MajorArkwolf opened this issue 2 years ago • 0 comments

The scope of the change is limited to the MAX6675::readFahrenheit function and removes the implicit conversion to a double and than the implicit conversion back to float. I can't see any benefit in needing the extra precision here and the result will likely be lost from the return value.

This change fixes the compiler warnings that are produced from this function and will avoid double arithmetic which is often less performant on embedded systems.

...\MAX6675 library\max6675.cpp: In member function 'float MAX6675::readFahrenheit()':
...\MAX6675 library\max6675.cpp:63:60: warning: implicit conversion from 'float' to 'double' to match other operand of binary expression [-Wdouble-promotion]
   63 | float MAX6675::readFahrenheit(void) { return readCelsius() * 9.0 / 5.0 + 32; }

MajorArkwolf avatar Feb 26 '23 03:02 MajorArkwolf