Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 08 Jan 2002 15:41:34 +1100
From:      Peter Jeremy <peter.jeremy@alcatel.com.au>
To:        Mike Silbersack <silby@silby.com>
Cc:        Bruce Evans <bde@zeta.org.au>, cvs-committers@FreeBSD.ORG, cvs-all@FreeBSD.ORG
Subject:   Re: cvs commit: src/sys/kern uipc_socket2.c
Message-ID:  <20020108154134.E561@gsmx07.alcatel.com.au>
In-Reply-To: <20020107194722.G31122-100000@patrocles.silby.com>; from silby@silby.com on Mon, Jan 07, 2002 at 07:58:52PM %2B0000
References:  <20020107160807.V376-100000@gamplex.bde.org> <20020107194722.G31122-100000@patrocles.silby.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 2002-Jan-07 19:58:52 +0000, Mike Silbersack <silby@silby.com> wrote:
>If we use the simple macro
>#define min(a,b) (((a)<(b))?(a):(b))
>and a & b's types differ, does the compiler promote the lesser size to the
>greater size for the purpose of the comparison, or does the comparison
>occur only on the size of the lesser argument?

I don't have a copy of the ISO standards, but K&R2 states:
A7.9 Relational operators
...
The usual arithmetic conversions are performed on arithmetic operands.
...

"Usual arithmetic conversions" are defined in A6.5 and have the intent
that the values of both operands will be preserved by the conversion.
There are a few gotchas:
- comparing int/long to float may lose precision
- if long is 64-bits, comparing long to double may lose precision
- comparing signed to unsigned values with the same size may produce
  unexpected results when then signed operand is negative.

Peter

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




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