Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What's the difference

 
Brian Snyder
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
0x45 in hexadecimal and just plain old 45 in hexadecimal?
Thanks in advance for your help.
 
Art Metzer
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure what you mean, Brian.
Java interprets the literal 0x45 as a hexadecimal value, equivalent to decimal 69, and furthermore, I believe, treats it as an int.
Java interprets the literal 45 as an int, equivalent to decimal 45.
Of course, hexadecimal 45 = hexadecimal 45, but Java will not treat a literal as a hexadecimal without the 0x (or 0X) prefix.
Art
 
Brian Snyder
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. That really helped!
 
Art Metzer
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cool.
Art
 
Joseph Russell
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm fairly new to programming and so maybe this seems like a dumb question but I have yet to see a reason to convert hex to binary or decimal or vice-versa. What are some real life situations where this is needed?
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only answer there is - visual display. Hex A0, Dec 160 and Binary 10100000 are all the same value to the computer. However, 160 is the 'Hard Space' used in HTML and interperted as such in beowsers and html editors. All you see is a space. When we converted to jsp, this started throwing parse exceptions in TomCat. A HexEditor was used to find these and change them to Hex 20 or Dec 32 the actual space character.
Using a display program that will show you the binary equivelent to a number can be helpful in understand bit operations. Read Cat and Mouse Game with Bits pay attention to the Applet at the end


------------------
Hope This Helps
Carl Trusiak
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The binary conversions are needed if you are going to work with bit operators.
Course most of us don't want to, but if you work in MicroEdition for embedded chips (like for you thermostat, or your cell phone menu etc.) space is at a premium and they tend to use bit operators alot to save space. I'm sure they get to thinking in binary alot.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic