Sorry for sending two messages, I had a problem in my connection
and thought the first mail was lost (it wasn't even in the system
log) so I wrote another...
-- Cassino
Thanks chaps: the operators are now doing what I hoped.
Learnt a valuable lesson today: if one is going to twiddle
bits it helps if one is familiar with the bits one is
twiddling. :)
J.
+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+0+
www:http://www.elephant.org/~azazel/
mail: [EMAIL PRO
Actually, they all make sense. It's plain 2's complement binary
arithmatic.
First of all, 0xF0F0F0F0 is a negative (signed) integer number. So
assigning it to a long makes it 0xF0F0F0F0L.
This accounts for the fact that all 1's are shifted in when you shift
right, even if you use '>>>'.
tterns. As I see it,
>one
> of two things is happening.
>
> 1. There's a bug in the JDK and bitwise operators don't work properly, which
> seems unlikely.
> 2.The dprint function is not printing the actual bit-strings but I can't see why.
>
>
&
Hi Jeremy.
I guess your problem is the size of long. It has 64 bits and
not only the 32 bits you are using. If you change your program
to:
n = 0xf0f0f0f0L;
it should work. If you don't do this, higher bits get set
to 1 and the output of your program is right (although it does
not show these hi
Hi Jeremy.
Maybe your problem is the long type size: it has 64 bits, not
only the 32 bits you are using. If you change your program to:
n = 0xf0f0f0f0L;
You'll get the expected result. When you don't do it, higher
bits are set to 1 and the output seems wrong (only seems).
Try using:
System.o
g.
1. There's a bug in the JDK and bitwise operators don't work properly, which
seems unlikely.
2. The dprint function is not printing the actual bit-strings but I can't see why.
public class pubtest
{
public static void main(String args[])
{