# Programmer Certification Study

Rahul Pawar

Ranch Hand

Posts: 38

Cindy Glass

"The Hood"

Sheriff

Sheriff

Posts: 8521

posted 14 years ago

- 0

using java? or doing it by hand?

"JavaRanch, where the deer and the Certified play" - David O'Meara

Rahul Pawar

Ranch Hand

Posts: 38

Rahul Pawar

Ranch Hand

Posts: 38

posted 14 years ago

thanks for ur reply but still i need to know how to do conversion without using valueOf() method ?

thanks once again

rahul

- 0

Originally posted by Cindy Glass:

OK

The Integer class has a method valueOf(String 2, radix r); That takes the string representation of a number and converts it to the base that you feed in in r.

So to convert 12345 to octal

Integer x = Integer.valueOf(12345, 8);

To convert to hex

Integer x = Integer.valueOf(12345, 16);

thanks for ur reply but still i need to know how to do conversion without using valueOf() method ?

thanks once again

rahul

Cindy Glass

"The Hood"

Sheriff

Sheriff

Posts: 8521

posted 14 years ago

- 0

ok.

The Integer class has two methods toHexString and toOctalString.

String s1 = Integer.toHexString(12345);

String s2 = Integer.toOctalString(12345);

The Integer class has two methods toHexString and toOctalString.

String s1 = Integer.toHexString(12345);

String s2 = Integer.toOctalString(12345);

"JavaRanch, where the deer and the Certified play" - David O'Meara

Cindy Glass

"The Hood"

Sheriff

Sheriff

Posts: 8521

posted 14 years ago

- 0

Well, that was the first question. I guess you want to be able to do it by hand.

(BTW I deleted my first reply - the syntax is WAY wrong).

Normally I do it the hard way. To convert to octal

Assuming a number less that 32,768

____ ___ __ _

4096 512 64 8 etc.

Take the number in decimal and find out how may 4096's are in it. Put that number over the 4096 space. Take the remainder and find out how many 512's are in it, put that over the 512 space. Then find how many 64's are in the remainder, put it over the 64 space. The last number should be <=7 put it over the 8. Now it is in Octal.

[This message has been edited by Cindy Glass (edited March 13, 2001).]

(BTW I deleted my first reply - the syntax is WAY wrong).

Normally I do it the hard way. To convert to octal

Assuming a number less that 32,768

____ ___ __ _

4096 512 64 8 etc.

Take the number in decimal and find out how may 4096's are in it. Put that number over the 4096 space. Take the remainder and find out how many 512's are in it, put that over the 512 space. Then find how many 64's are in the remainder, put it over the 64 space. The last number should be <=7 put it over the 8. Now it is in Octal.

[This message has been edited by Cindy Glass (edited March 13, 2001).]

"JavaRanch, where the deer and the Certified play" - David O'Meara

Rahul Pawar

Ranch Hand

Posts: 38

posted 14 years ago

- 0

thanks for ur immediate reply but still i am confuse about conversion .

will u give me all the details along with ex. so that i can understand .

thank u very much for ur reply

rahul

will u give me all the details along with ex. so that i can understand .

thank u very much for ur reply

rahul

Originally posted by Cindy Glass:

Well, that was the first question. I guess you want to be able to do it by hand.

(BTW I deleted my first reply - the syntax is WAY wrong).

Normally I do it the hard way. To convert to octal

Assuming a number less that 32,768

____ ___ __ _

4096 512 64 8 etc.

Take the number in decimal and find out how may 4096's are in it. Put that number over the 4096 space. Take the remainder and find out how many 512's are in it, put that over the 512 space. Then find how many 64's are in the remainder, put it over the 64 space. The last number should be <=7 put it over the 8. Now it is in Octal.

[This message has been edited by Cindy Glass (edited March 13, 2001).]

Rahul Pawar

Ranch Hand

Posts: 38

Cindy Glass

"The Hood"

Sheriff

Sheriff

Posts: 8521

posted 14 years ago

- 0

You really need to get a Math tutorial. I haven't really found a good one but:

http://www.wtps.org/wths/imc/math.htm

Meanwhile I found this number converter that is cute:

http://www.uacch.cc.ar.us/science/numnotation.htm

http://www.wtps.org/wths/imc/math.htm

Meanwhile I found this number converter that is cute:

http://www.uacch.cc.ar.us/science/numnotation.htm

"JavaRanch, where the deer and the Certified play" - David O'Meara

Elizabeth Jacob

Greenhorn

Posts: 28

posted 14 years ago

- 0

Hi Rahul,

Are you familiar with binary conversions?

As binary is,representing an integer to its base 2,an octal is representing an integer to its base 8 and hex is to the base 16.

You can convert the number to an octal the same way you find the

binary,except that you divide it by 8 instead of doing it by 2.

IF you want a detailed explanation pl ask.

Elizabeth.

Are you familiar with binary conversions?

As binary is,representing an integer to its base 2,an octal is representing an integer to its base 8 and hex is to the base 16.

You can convert the number to an octal the same way you find the

binary,except that you divide it by 8 instead of doing it by 2.

IF you want a detailed explanation pl ask.

Elizabeth.

Rahul Pawar

Ranch Hand

Posts: 38

Albert Gray

Ranch Hand

Posts: 43

posted 14 years ago

- 0

If you know how to convert a floating point decimal number to a floating point binary and vise versa

Albert

Albert

Originally posted by Elizabeth Jacob:

Hi Rahul,

Are you familiar with binary conversions?

As binary is,representing an integer to its base 2,an octal is representing an integer to its base 8 and hex is to the base 16.

You can convert the number to an octal the same way you find the

binary,except that you divide it by 8 instead of doing it by 2.

IF you want a detailed explanation pl ask.

Elizabeth.

I agree. Here's the link: http://aspose.com/file-tools |