On 2020-04-19 12:23:03 +0200, Niels Möller wrote: > >> BTW, do we have any C implementation where INT_MAX + INT_MIN == 0, > >> i.e., > >> not using two's complement? > > > > I'm almost sure the compiler can optimise that out at compile time. > > Agreed. But if we attempt to support non two's complement, it would be > interesting if there were some obscure but conforming C implementation > that could be used to test it. Some C interpreter, not targeting any > particular hardware, would do fine for this purpose.
I think that in general, you should not write code that depends on whether INT_MAX + INT_MIN == 0 or not (the constant INT_MAX + INT_MIN might be useful in some rare cases, but I think that testing whether this constant is 0 or not should be forbidden). This can mean that code on implementations with INT_MAX + INT_MIN == 0 would be less optimized, but no-one cares. -- Vincent Lefèvre <vinc...@vinc17.net> - Web: <https://www.vinc17.net/> 100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/> Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon) _______________________________________________ gmp-devel mailing list gmp-devel@gmplib.org https://gmplib.org/mailman/listinfo/gmp-devel