This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
hi all, i do'nt know what differences between Sample1 & Sample2. code 1: class Sample1{ public static void main(String args[]){ int i=-1; i=i<<-2; System.out.println(i); } } code 2: class Sample2{ public static void main(String args[]){ int i=-1; i=i<<2; System.out.println(i); } } thank you!!
If the promoted type of the left-hand operand is int, only the five lowest-order bits of the right-hand operand are used as the shift distance. It is as if the right-hand operand were subjected to a bitwise logical AND operator & (�15.22.1) with the mask value 0x1f. The shift distance actually used is therefore always in the range 0 to 31, inclusive.
Java Language Specification. So actually: shfit -1 is shift to 31 shift -2 is shift to 30 shift -3 is shift to 29 shift -4 is shift to 28 . . . . . . . . . . . . . [ March 15, 2004: Message edited by: Igor Ko ]
dlc, Welcome to JavaRanch! We ain't got many rules 'round these parts, but we do got one. Please change your display name to comply with The JavaRanch Naming Policy. Thanks Pardner! Hope to see you 'round the Ranch!