wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes How to think in Octal? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "How to think in Octal?" Watch "How to think in Octal?" New topic
Author

How to think in Octal?

DD
Ranch Hand

Joined: Oct 13, 2000
Posts: 66
Hello everybody,
can anybody tell me how to think (and count) in Octal?
I mean...what if I get a question which asks me to tell the diff. b/w a decimal no. and an octal one I just realized that I'll be stumped!
-Deb
sean cee
Ranch Hand

Joined: Oct 24, 2000
Posts: 115
Hi,
It's simple..
Decimal 0 1 2 3 4 5 6 7 8 9 then 10
Octal 0 1 2 3 4 5 6 7 8 then 10
how to convert Dec 113 to Oct?
113 div 8 = 14 with remainder 1
14 div 8 = 1 with remainder 6
1 div 8 = 0 with remainder 1
divide until you get 0 ... then look at the remainders ...
read them up from bottom..
so Decimal 113 = Octal 161
How do you convert Octal 161 to Dec 113?
gotta memorise one thing :
right most digit means 8 to the power of 0
2nd to right most digit means 8 to the power of 1
3rd to right most digit means 8 to the power of 2
so on...
take 161 ..
multiply right most 1 by 8 to the power of 0 which is 1 .
multiply 6 by 8 to the power of 1 which is 48.
multiply left most 1 by 8 to the power of 2 wichi is 64 .
add those three results which is 113 .. back to our octal number.
I don't know if I make any sense.. but this is kinna hard to explain over a message post.
Hope this helps

Sean <br />SCJP2, SCJP2p1.4, SCWCD
Graeme Brown
Ranch Hand

Joined: Oct 13, 2000
Posts: 193
Here is a quick way to convert binary to octal, just put it into groups of three digits and convert each. Example:
54321 decimal
= 1101010000110001 binary
split into groups (and pad with leading zeroes)
001 101 010 000 110 001
= 152061 octal
of course it is just as easy to go the other way
12345 octal
= 001 010 011 100 101 binary

[This message has been edited by Graeme Brown (edited October 25, 2000).]
DD
Ranch Hand

Joined: Oct 13, 2000
Posts: 66
Sean, thanks a million
the concept is now crystal clear thanks to u...
actually I used to do the same before I got hold of a scientific calculator during my engineering days!!! Guess that is an example of too much technology to do simple things...
anyhow....thanks again
-Deb
DD
Ranch Hand

Joined: Oct 13, 2000
Posts: 66
Thanks Graeme,
that was a pretty helpful way too
-Deb
 
 
subject: How to think in Octal?