This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: portable numerical limits?


> What is the portable C trick to generate, say, the largest
> representable value of type `short'?

#ifdef __STDC__
#include <limits.h>
#else
#define SHRT_MAX (~(short)((short)1 << (sizeof(short) * 8 - 1)))
#endif

and then use SHRT_MAX.

> The question is, how portable (specifically in the Guile context) 
> is the assumption that signed integers are always 2's complement? 

I think you can safely assume 2's complement, at least for anything
that Guile is likely to run on.  (I guess there might be some
ancient CDC machine somewhere still using 1's complement, but
who cares?)

	--Per Bothner
Cygnus Solutions     bothner@cygnus.com     http://www.cygnus.com/~bothner