With this fix the function still returns negative values, which is wrong. But we keep this behaviour to maintain backwards compatibility.