[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: gEDA-user: PCB nanometer git tree



On Fri, 12 Aug 2011 23:31:39 +0200 (CEST)
karl@xxxxxxxxxxx (Karl Hammar) wrote:

> Andrew Poelstra:
> > On Thu, Aug 11, 2011 at 09:30:34PM +0200, Karl Hammar wrote:
> ...
> > > -#define LARGE_VALUE            (LONG_MAX / 2 - 1) /* maximum
> > > extent of board and elements */ +#define LARGE_VALUE
> > > LONG_MAX /* (LONG_MAX / 2 - 1) maximum extent of board and
> > > elements */
> ...
> > > Why do you want to use only half the range?
> >
> > So that the width of a "max width" box can be calculated as
> > LARGE_VALUE - (-LARGE_VALUE) without overflow,
> 
> Hmm, wouldn't it be better to use unsigned here?

IMHO, the many subtle pitfalls that crop up when unsigned arithmetic
is used throughout a large C program far outweigh the benefit of the
extra half-scale range.  Compiler warnings from gcc can catch some
problems (certainly not all) and usually it takes tons of effort to
make the code âwarning-cleanâ when you enable all the signed-unsigned
type warnings.  In my experience, I've found that, it is best to avoid
unsigned arithmetic as much as possible.

Regards,
Colin


_______________________________________________
geda-user mailing list
geda-user@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user