On Fri, 19 May 2006 at 17:13 -0600, Michael L Torrie wrote: > On Fri, 2006-05-19 at 15:21 -0600, Stephen Ward wrote: > > >> I haven't looked at the spec to see what exactly > > >> causes the bytes to get promoted to ints, but they > > >> do. It's probably the fact that a literal number is > > >> interpreted as an int, not a byte, so byteval << intval > > >> causes the byte to be promoted to an int. > > > > Actually, I believe the << operator promotes each of its operands to ints. > > Is this not a bad thing? I definitely wouldn't want a number I'm > shifting to be casted to an int as that can change the meaning of the > shift. > > But Java doesn't have unsigned numbers, right? > > I'll add that to my list of reasons to dislike Java.
Well that's what C does.
int main(void)
{
printf("%x %x\n",
((unsigned char)0xff) << 8,
((char)0xff) << 8);
}
produces
ff00 ffffff00
Neither of which is a char, unsigned or no.
--
Hans Fugal ; http://hans.fugal.net
There's nothing remarkable about it. All one has to do is hit the
right keys at the right time and the instrument plays itself.
-- Johann Sebastian Bach
signature.asc
Description: Digital signature
/* PLUG: http://plug.org, #utah on irc.freenode.net Unsubscribe: http://plug.org/mailman/options/plug Don't fear the penguin. */
