Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 13 Mar 2000 08:31:51 -0800 (PST)
From:      John Polstra <jdp@polstra.com>
To:        bde@zeta.org.au
Cc:        current@freebsd.org
Subject:   Re: MAX_UID ?
Message-ID:  <200003131631.IAA52433@vashon.polstra.com>
In-Reply-To: <Pine.BSF.4.21.0003131708430.931-100000@alphplex.bde.org>
References:  <Pine.BSF.4.21.0003131708430.931-100000@alphplex.bde.org>

next in thread | previous in thread | raw e-mail | index | archive | help
In article <Pine.BSF.4.21.0003131708430.931-100000@alphplex.bde.org>,
Bruce Evans  <bde@zeta.org.au> wrote:
> 
> I would prefer standard maxof() and minof() interfaces that work on
> any arithmetic type.  These can almost be written in portable C, at
> least in C89 where types are restricted to char, signed char, ...,
> long double:
> 
> #define isfloat(type)	((type)0.5 != 0)
> #define issigned(type)	((type)-1 < 0)
> #define isschar(type)	(!isfloat(type) && issigned(type) && sizeof(type) == 1)
> #define isuchar(type)	(!isfloat(type) && !issigned(type) && sizeof(type) == 1)
> ...
> #define maxof(type)	((type)(isschar(type) ? SCHAR_MAX :
> 				isuchar(type) ? UCHAR_MAX ...))

I like this idea.

John


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200003131631.IAA52433>