Java Glossary : octal

CMP home Java glossary home Menu no menu Last updated 2004-06-28 by Roedy Green ©1996-2004 Canadian Mind Products

Java definitions: 0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

You are here : home : Java Glossary : O words : octal.

octal
Base 8 numbers, e.g. 755, made of the digits 0..7 only This is the number system we would have used had we eight fingers instead of ten. You can display in octal using code like this: You can convert an octal String to internal binary like this: Since the computer exclusively uses binary internally (possibly excluding BigDecimal), it makes no sense to talk about converting an int from octal to decimal or back, only a String.

In Java you can create octal literals simply by adding a leading zero like this:

Be careful! It is very common to specify an octal literal by mistake in Java and scratch your head for hours trying to figure out the problem.

The computer chip works internally in binary (base 2 numbers), with numbers made only of the digits 0 and 1, low voltage/high voltage. Binary numbers are somewhat bulky to write out, so they are usually written in base 16, hex, but sometimes in base 8, octal, e.g. the unix CHMOD command. It is very easy to convert octal to binary and visa versa using the following table. For example, the octal number 750 is 111101000 in binary. Converting between decimal and octal is more difficult. You must do successive divisions and moduluses by 10 or 8.

Decimal Octal Binary
0 0 000
1 1 001
2 2 010
3 3 011
4 4 100
5 5 101
6 6 110
7 7 111
binary formats ¤ binary ¤ chmod ¤ conversion ¤ hexadecimal ¤ Learn To Count Applet to sharpen your intuition on how binary, hex, and octol work ¤ literals ¤ radix


CMP logo
CMP_home
home
Canadian Mind Products CSS
HTML Checked!
ICRA ratings logo
mindprod.com IP:[24.87.56.253]
Your IP:[80.134.30.163]
You are visitor number 2082.
Please send errors, omissions and suggestions
to improve this page to Roedy Green.
You can get a fresh copy of this page from: or possibly from your local J: drive mirror:
http://mindprod.com/jgloss/octal.html J:\mindprod\jgloss\octal.html