Andy,
I think if the question wants to answer negative integer, we can add a line (bold below) to get the absolute value of x before we evaluate. For example, -512 will return 0 with your original code, but after taking abs, it will return 1. Just a small point.