On 04/18/2014 07:50 AM, Tom Musta wrote:
> +    uint64_t unsig;
> +    if (in >= 0) {
> +        unsig = in;
> +    } else {                      /* negative (possibly BADINT) */
> +        if (in == INT64_MIN) {
> +            unsig = 1ull << 63;   /* special case */
> +        } else {
> +            unsig = -in;          /* invert */
> +        }
> +    }

I know the other code you imported does this but... ug.

How about just

    uint64_t unsig = in;
    if (in < 0) {
        unsig = -unsig;
    }

which neatly handles the INT_MIN thing in a defined way.


r~

Reply via email to