On Mon, Nov 25, 2002 at 11:29:01AM -0500, Dan Sugalski wrote:
> At 4:04 PM +0000 11/25/02, Nicholas Clark wrote:

> >Is there any speed advantage in truncating by casting via a C type
> >[eg a = (int)(short) b]
> >rather than  and on a bitmask
> >[eg a = b & 0xFFFF]
> >?
> >
> >We're going to have to do that latter to make it work on Crays anyway, so is
> >a conditional compile to chose between the two worth it?
> 
> The bitmask doesn't sign-extend where the casting will, which could 
> be an issue.

That still lets us halve our conditional code. :-)
(do all the unsigned with masks)

And we ought to make a generic "safe" version of the code for signed
truncation that works for platforms that are any or all of the following
holds

1: no type of that size (eg Crays)
2: signed integer truncation (UTS) [and other OSes on S/390 processors?]
3: not 2s complement [no examples]

Nicholas Clark

Reply via email to