Java Program with binary operations


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Java Program with binary operations

  1. #1
    Join Date
    Feb 2005
    Location
    USA
    Posts
    3

    Exclamation Java Program with binary operations

    Hey there guys.

    Let's say I have: int temp=0xcf4f3c09. And I do a temp>>24;
    I then have 0x000000cf, but in java, instead of being 207, it's
    -49, the two's complement of 207. How do I change it to 207?

  2. #2
    Join Date
    May 2004
    Location
    Durham, UK
    Posts
    174
    Hi,

    Just and the result with 255 i.e.

    temp = temp & 255 and it should make it 207
    Hope this helps
    Graham

    Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, and if they get mad, you are a mile away and you have their shoes ;-)

    http://www.grahamrobinsonsoftware.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center