Date: Mon, 23 Feb 1998 18:51:29 +0000 From: Bob Bishop <rb@gid.co.uk> To: Jon Loeliger <jdl@jdl.com> Cc: hackers@FreeBSD.ORG Subject: Re: My Compiler Confusion Message-ID: <l0302090ab1176ea3b860@[194.32.164.2]> In-Reply-To: <199802231619.KAA01344@chrome.jdl.com>
next in thread | previous in thread | raw e-mail | index | archive | help
>What are they(*) _really_ trying to do with that cast-cast-compare code? >((*) I am not the original author of this Work of Art...) I reckon they're trying to avoid using an FP constant if the integer is truly equivalent; might be cheaper on some targets. >Given that the constant really _doesn't_ fit in the integer, I think >the intent of this code is to essentially determine that fact and >then cause the compiler to do something else (more correct), than >silently substitute 0 in the generated code, as it does on the Solaris >box using the bbc or gcc. Well, according to the only reference I have to hand, "When a value of floating type is converted to integral type, the fractional part is discarded; if the resulting value cannot be represented in the integral type, the behaviour is undefined." (K&R II A6.3). So the Solaris behaviour is just fine. >How _should_ this cast-cast-compare test really be written to be >more correct? As a range test? Invert the test by taking max-int >and placing it in a float for the compare, which must be done >using a floating compare? If I'm right about what they're trying to do, the code is probably OK. -- Bob Bishop (0118) 977 4017 international code +44 118 rb@gid.co.uk fax (0118) 989 4254 between 0800 and 1800 UK To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?l0302090ab1176ea3b860>