IntelliJ Java IDE
The moose likes Beginning Java and the fly likes Hexadecimal Conversion Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Hexadecimal Conversion" Watch "Hexadecimal Conversion" New topic
Author

Hexadecimal Conversion

Brusse James
Greenhorn

Joined: Nov 22, 2002
Posts: 7
This is probably way to easy, but does anyone have any suggestions as to how I can easily convert an integer input into hexadecimal. This assignment calls for the user to be able to enter a number from 0-100,000, and that number be converted to hex. There has to be an easier way of converting than a huge branching if...else if..etc. Any help appreciated
Manish Hatwalne
Ranch Hand

Joined: Sep 22, 2001
Posts: 2559

Integer.toHexString(int_value_here);
HTH,
- Manish
Brusse James
Greenhorn

Joined: Nov 22, 2002
Posts: 7
Manish,
Thank you very much that worked perfectly, and saved me several pages.
Brusse James
Jim Ronholm
Greenhorn

Joined: Nov 15, 2002
Posts: 16

Or you could write an algorithm using / and % to convert it. (Previous answer was good, but there might come a time when you would need to do this yourself.)
Jim
 
 
subject: Hexadecimal Conversion
 
Threads others viewed
Incrementing alphanumeric string
Java Object Reference Variable Question
MetaCharacter Problem(See if you can Solve it)
char c = �\ucafe�;
Adding Hexadecimal to byte array
MyEclipse, The Clear Choice

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture