I have to do a bit more fine grain than unsigned int comparison.
What is the correct way with the current Arduino IDE 1.8.12 to do the comparison:
Variable power is float.
A,
if ( power < float(17.10) && power >= float(16.25) )
if ( power < 13) )
B,
if ( power < 17.10 && power >= 16.25 )
if ( power < 13) )
A and B should both work but I prefer B.
This:
float(17.10)
is redundant. "17.10" cannot be anything BUT a float.
Regards,
Ray L.
Well, I suppose it could be a double. That matters in some situations but probably not with an Arduino.
Does the compiler "know" that the literal 17.10 can sort-of fit into a float and is not appreciably helped by using a double? I think that the .1 part might be an issue.
Floating point literals without a suffix are of type "double", regardless of their value.
https://en.cppreference.com/w/cpp/language/floating_literal
Pieter