I'm trying to run a calculation but I'm not getting the correct result and struggling to understand why.
float Signal = ((20 - 0) / (20 - 4)) * (F5 - 4) + 0;
The first term
((20 - 0) / (20 - 4)) is calculated using integer arithmetic, giving a value of
1. This makes the final result
8 regardless of the type of
F5. If you want it to happen in floating point, use floating point constants
float Signal = ((20f - 0f) / (20f - 4f)) * (F5 - 4f) + 0f;
Technically you don't need all the constants to be floats due to numeric promotion, but it is much clearer to those reading your code that you intended for everything to be a float.