On Sun, 13 Jul 2003, Marcel Moolenaar wrote: > On Sun, Jul 13, 2003 at 08:23:54AM -0500, David Leimbach wrote: > > > > This is a good policy in general, however, one could easily argue that > > what > > is trying to be determined with signedness and such being > > less-than-compared > > to 0 isn't really a big deal and possibly the only way to implement this > > numeric_limits<T>::digits thing without any type introspection which > > C++ currently > > lacks. > > What about? > > #define issigned(T) (((T)(0)>(T)(~0)) ? 1 : 0) This is worse than any version that uses -1 instead of ~0, since ~0 gives implementation-defined behaviour. I think it can set trap bits. Anyway, the value of ~0 is unclear. I think it is -0 == 0 on 1's complement machines. Since its value is unclear, the result of converting this value to even an unsigned type T is also unclear. I think the above actually does work for the 3 representations in C99 iff ~0 has no trap bits, but this is unclear. These problems are avoided by using plain -1. BruceReceived on Sun Jul 13 2003 - 11:39:03 UTC
This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:15 UTC