Quote Originally Posted by AlionSolutions
Ok, now it returns another value, which amazes me much more:

0.4994994994995
All this talk about the accuracy of floating point math, although theoretically correct, is absolutely irrelevant in the context of the error the OP is seeing. Doubles have an accuracy of 15 (approx) digits, whereas this answer of 0.4994994994995 is wrong in the fourth digit.

If OP said that his answer was 0.499999999999905, then the above discussion makes sense. But when his answer is wrong in the fourth digit, it's a red herring.

Clearly there is something else going on here.

I tend to think that Wildfrog's first question, which remains unanswered, is the correct approach: How did you check the value of getaspectratio()? Are you printf'ing it? If so give us the format string. Are you certain that you are actually using the code you posted, or have you simplified and, and without testing the simplified code, have you made the incorrect assumption that the output remains the same? Are you actually outputting the value of "ratio", and are you outputting it while it is still in-scope?

Mike