gnugo-devel
[Top][All Lists]
Advanced

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

Re: [gnugo-devel] Cast to unsigned


From: Arend Bayer
Subject: Re: [gnugo-devel] Cast to unsigned
Date: Thu, 7 Aug 2003 21:03:28 +0200 (CEST)

Gunnar wrote:

> Arend wrote:
> > > Arend, you (I think) introduced casts to unsigned in some comparisons in
> > > cache.c.  One of them is in tt_get() and looks like this:
> > >
> > >   if ((unsigned) remaining_depth <= hn_get_remaining_depth(*node)) {
> > >     if (result)
> > >       *result = hn_get_result1(*node);
> > >     return 2;
> > >   }
> > >
> > > These give warnings about comparison between singed and unsigned,
> > > and before I try to fix them, I think that I must understand the
> > > reason for the cast. Can you elaborate?
> >
> > These were to avoid compiler warnings when .data in the hash nodes
> > was still unsigned (as it has to be).
>
> Does it really? I think it works with int too, although I would agree
> that unsigned makes it clearer, in particular if the highest bit is
> used. If we change to unsigned I would suggest adding casts to the

IIRC rotating out of the sign bit for negative ints is undefined or
implementation defined in ANSI C. That'd mean it has to be unsigned.

> hn_get_* macros instead. It should be cleaner than having lots of
> casts spread over the code.
That's true.

Arend






reply via email to

[Prev in Thread] Current Thread [Next in Thread]