tech-toolchain archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

minus operator applied to unsigned type



My compiler is confused. What does this mean? 
bmake cond.c(476)

static Boolean
CondCvtArg(char *str, double *value)
{
    char *eptr, ech;
    unsigned long l_val;
    double d_val;

    errno = 0;
    l_val = strtoul(str, &eptr, str[1] == 'x' ? 16 : 10);
    ech = *eptr;
    if (ech == 0 && errno != ERANGE) {
        d_val = str[0] == '-' ? -(double)-l_val : (double)l_val;
    } else {
...

I suppose:
d_val = (str[0] == '-') ? (double)(0-l_val) : (double)l_val;
or maybe if not in __LP64__
d_val = (str[0] == '-') ? (double)(0-(double)l_val) : (double)l_val;

Right?
There are several of these (for my compiler ambiguous) constructs in bmake.
I solved them just by adding a zero - hope that's what was originally meant.




Home | Main Index | Thread Index | Old Index