On Sat, Apr 18, 2009 at 12:09:10AM -0700, Christoph Otto via RT wrote: > On Wed Aug 06 20:07:05 2008, Whiteknight wrote: > > On Sat May 17 14:57:18 2008, pmichaud wrote: > > > On Mon Jul 17 11:59:47 2006, chip wrote: > > > > It's great to have INTVAL and UINTVAL, but without MAX_INTVAL it's > > kind of > > > > hard to work with them in some respects. All integral typedefs should > > > have > > > > min/max macros. Syntax not a big deal, it can be fixed later, just > > don't > > > > break anything when introducing them. > > > > > > Nothing has happened on this ticket since it was introduced in 2006. Do > > > we need MIN/MAX macros? If so, why, or where do we expect them to be > > used? > > > > > > Pm > > > > Defining them on a 2's complement machine would be easy as pie: > > > > #define MAX_UINTVAL (UINTVAL)((INTVAL)-1)
I think that that would be better defined in terms of ~0 > > #define MIN_UINTVAL (UINTVAL)0 This one, I think is correct. > > #define MAX_INTVAL (((INTVAL)-1) / 2) Eh? -1/2 is 0 for signed integer arithmetic. > > #define MIN_INTVAL ((~MAX_INTVAL) + 1) Even with the correct definition of MAX_INTVAL, that's going to be out by 1. For a two's complement system, it doesn't need the + 1. The logic that Perl 5 uses to do this is described here: http://perl5.git.perl.org/perl.git/blob/HEAD:/perl.h#l2178 I suspect it's portable. Nicholas Clark