aspose file tools*
The moose likes Java in General and the fly likes What does this hex (?) value mean / do?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "What does this hex (?) value mean / do??" Watch "What does this hex (?) value mean / do??" New topic
Author

What does this hex (?) value mean / do??

Gail Mikels
Ranch Hand

Joined: May 07, 2001
Posts: 634
I've been tasked with commenting some old code on our project, and am having trouble finding out what the following "if" condition is doing. I've figured out that the hex number there equates to decimal -32768, and I have a pretty good general idea of how the '&' operator works, but it's just not coming together for me. Any ideas?



Gail Mikels
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24166
    
  30

Imagine "FFFF8000" as a binary number: it's seventeen ones followed by fifteen zeros. The expression "if((0xFFFF8000 & status) != 0)" means "if one or more of the first seventeen bits of 'status' are set to one..." This kind of code is generally used to pack a whole bunch of boolean flags into one int, to save space.


[Jess in Action][AskingGoodQuestions]
Gail Mikels
Ranch Hand

Joined: May 07, 2001
Posts: 634
Wow. You're awesome. Thank you very much!!! OK if I include part of your explanation in the code comments?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24166
    
  30

Sure!
Gail Mikels
Ranch Hand

Joined: May 07, 2001
Posts: 634
JavaRanch should give you a raise!!
Ken Blair
Ranch Hand

Joined: Jul 15, 2003
Posts: 1078
I agree. I think they can afford to give him a 1000% raise.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What does this hex (?) value mean / do??
 
Similar Threads
Content is not allowed in prolog
a little BYTE of problem....
Arrays - How do I show the array index postion?
Retrieving LONGVARCAR data type from SQL Server
Session lost in Tomcat when POST is done from a remote computer