0.01F/0.499F
is evaluated at compile time. The precision used at compile time depends on the compiler and likely exceeds the micro-controller's. Thus either approach will typically provide the same code.
In the unlikelihood the compiler's precision is about the same as the micro-controller's float
and typical binary floating-point, the values 0.01F
and 0.499F
will not be exact but within 0.5 ULP (unit in the last place). The quotient 0.01F/0.499F
will be then within about sqrt(2)*0.5 ULP. Using 0.02004008016032064F
will be within 0.5 ULP. So under select situations, the constant will be better than the quotient.
Under more rare circumstances, a float
precision will be more than 0.02004008016032064F
and the quotient would be better.
In the end, recommend coding to whatever values are used to drive the equation. e.g. If 0.01
0.499
are the value of two resistors, use those 2 values.