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] |
[ This really probably belongs in comp.lang.c, but what the hell, I need it for Guile :-] What is the portable C trick to generate, say, the largest representable value of type `short'? I vaguely recall some bit-twiddling tricks, but don't want to trust my memory on this. If we assume 2's complement and 8-bit bytes (the latter is pretty safe, I suppose), then the following should do the trick: short max_short = ~(short)((short)1 << (sizeof(short) * 8 - 1)); The question is, how portable (specifically in the Guile context) is the assumption that signed integers are always 2's complement? thanks, mike.