• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Bitwise NOT ( ~ )

 
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

------------------
author of:
 
reply
    Bookmark Topic Watch Topic
  • New Topic