Hi friends, I want the method that how java compiler evaluate Bitwise NOT i.e " ~ " operator. I know the handy technique i.e, ~23 gives -24 and ~(-23) gives 22. But i want to know the whole game played by Java compiler in bits. Regards, Hassan.
You simply have to think in terms of bit patterns. Decimal notation is a lousy way to think about bit patterns because you have to remember all the powers of two. Write some Java programs to experiment, note that the Integer class has the very handy toBinaryString and toHexString methods for output in bit patterns and parseInt( String s, int radix) for input. Bill