aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes How do you convert dcimal to octal?? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "How do you convert dcimal to octal??" Watch "How do you convert dcimal to octal??" New topic
Author

How do you convert dcimal to octal??

Fei Ng
Ranch Hand

Joined: Aug 26, 2000
Posts: 1241
How do you convert dcimal to octal??

thanks.
n sky
Greenhorn

Joined: Oct 04, 2001
Posts: 3
personally, i'd tend to use a scientific calculator -- but if you don't have one available, the other easy thing to do would be to write a small utility in java to do it for you -- in fact, there's at least one utility class that already does most of the work for you, with the signature:
public static String toOctalString(int i) // for strings
you can also use the calculator at this page:
http://www.science-ebooks.com/electronics/new_page_12.htm
hope that helps, :-)
--- n sky ---
Fei Ng
Ranch Hand

Joined: Aug 26, 2000
Posts: 1241
oh no.. by hand.
Anyone know a easy method to do it on paper?
vivek j alva
Greenhorn

Joined: Oct 12, 2001
Posts: 3
for example say 35 is decimal number.
than octal form of it would be 43.
you have to divide 35 by 8 your remainder=3 qotient=4
again
divide qotient by 8 your remainder=4 qotient=0
now read remainder from down to up.
you will get 43.
Mr Iftikhar
Ranch Hand

Joined: Oct 12, 2001
Posts: 39

System.out.println(Integer.toOctalString(9));
This will print the octal equivalent of decimal 9.
or you can save you value.
String s = Integer.toOctalString(9);


java language
Jane Griscti
Ranch Hand

Joined: Aug 30, 2000
Posts: 3141
Hi Fei,
I've got some notes at http://www.janeg.ca/scjp/oper/binhex.html that might help.
------------------
Jane Griscti
Sun Certified Programmer for the Java� 2 Platform


Jane Griscti
SCJP, Co-author Mike Meyers' Java 2 Certification Passport
Fei Ng
Ranch Hand

Joined: Aug 26, 2000
Posts: 1241
thanks Jane Griscti!!!
great link!

and thanks to all!!
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: How do you convert dcimal to octal??
 
Similar Threads
Hexidecimal and octal question!!
Hex and Octal
unsigned right shift
Shift operators !
decimal ->octal & decimal ->hexadecimal