Hacker News new | ask | show | jobs
by ajuc 4952 days ago
You should check before the operation that can produce result outside the valid range anyway.

Wrong example:

    unsigned int z = x - y;
    if (z > BIG_NUMBER) {
        return false;
    }
Good example:

    if (y > x) {
        return false;
    }
    unsigned int z = x - y;