I was working on readability for CS50 PS 2, and was getting incorrect outputs on the grade level.
Debugging showed that the input values were correct, but the output was wrong. Hand calculating using the inputs gave the correct answer.
I simplified the first part of the equation and found this:
Using the values of 214
for L
and 56
for W
, the expression:
float R = (0.0588 * (L / W) * 100);
outputs 17.64
, which is wrong.
When I use:
float R = (0.0588 * L / W * 100);
it outputs 22.47
, which is correct.
I can't figure out why.