For the large sentence test of pset2's Readability task, I was constantly getting Grade 8 instead of Grade 7, even after checking the counting went properly. After roughly an hour of debugging I've narrowed the issue down to this line:

float l = (100 * lettercount) / wordcount, s = (100 * sentencecount) / wordcount;

The issue seems to be that L and S end up being integers (in this case 417.0000 and 4.0000), whereas the values they should have are 417.391304348 and 7.45565217391 respectively. I can't figure out why this is happening. It seems as if it's being truncated but I have no idea where. Can anyone help?

1 Answer 1


Try 100.0. Dividing two integers will result in an integer again (truncating the result, ignoring the fractional part), if at least one operand is floating point, it's floating point division instead.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .