This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Changing decimal to octale (and etc.) Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Changing decimal to octale (and etc.)" Watch "Changing decimal to octale (and etc.)" New topic
Author

Changing decimal to octale (and etc.)

Justin Porter
Ranch Hand

Joined: Nov 20, 2004
Posts: 34
Hey, what is the object/command that I need in order to change a decimal number to octale, or to binary, or to hexidecimal, etc. Is there a command like Integer.toOctale? Thanks in advance!


Want a free iPod, digital camera, or $300 cash? Completely legit offer at <a href="http://www.geocities.com/pricklymustard/freestuff.html" target="_blank" rel="nofollow">http://www.geocities.com/pricklymustard/freestuff.html</a> . I am looking for referrals which is why I need YOU!
Jeff Bosch
Ranch Hand

Joined: Jul 30, 2003
Posts: 804
Hi, Justin -

Thre's no such number system as "octale".

If you're looking for "octal", do you want the number or the string representation of the number?

Cheers,

Jeff


Give a man a fish, he'll eat for one day. <br />Teach a man to fish, he'll drink all your beer.<br /> <br />Cheers,<br /> <br />Jeff (SCJP 1.4, SCJD in progress, if you can call that progress...)
Justin Porter
Ranch Hand

Joined: Nov 20, 2004
Posts: 34
Either would work, string respresentation would be nice but I'd like to know both. Thanks!
Jeff Bosch
Ranch Hand

Joined: Jul 30, 2003
Posts: 804
If you have an int, you can get the String representation with:



Or you can get the number if you started with a String with:



These are both static methods of class Integer, so you don't need an Integer object. There are other ways to do this, but these give you the general idea. I highly recommend getting familiar with the API docs, because you could have found the answer on your own in about a minute.
Justin Porter
Ranch Hand

Joined: Nov 20, 2004
Posts: 34
Thanks Jeff, I'll try that out!
Jeff Bosch
Ranch Hand

Joined: Jul 30, 2003
Posts: 804
Cool. You're welcome!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Changing decimal to octale (and etc.)
 
Similar Threads
Numerical conversions in SCJP exam?
appletviewer
hexadecimal numbers
logic needed
Double arithmetic