## Octal numbering system

### Octal numbering system

Or number systems in general, other than decimal...

Can anyone explain, or point me in the direction of a good explanation of octal numbers, please?

I'm working on a language and I want it to have an octal numbering system.

Thank you in advance.

Can anyone explain, or point me in the direction of a good explanation of octal numbers, please?

I'm working on a language and I want it to have an octal numbering system.

Thank you in advance.

### Re: Octal numbering system

Are you working on a number system for a spider culture? This would be much interesting!

For the explanation of the octal system and place-value-systems in general, we start out considering what is already well-known to us: the decimal system. Here, you have ten digits: 0 to 9. The base is 10. Every digit is a number, but not every number is a digit. Note that 10 is a number, not a digit. As we are in the decimal system, we just write 10. You could also write 1010, which just means that the number 10 is interpreted as a number in the decimal system. The number 10 represented by the string '10' just means 1 x 10 + 0. The string '11' means 1 x 10 + 1, and so on, where x means "times". So, the string 10 is just a shorter way to write the acutal number. This is called "denominational number system" or "place-value system", as different places in the string representing the number have different values:

For exemple, let's take the number 365. It is represented by a string '365'. You number the places right to left: the 5 is in a place with the position number 0, the 6 is in the place with the position number 1 and the 3 is in a place with the position number 2. Remember that x0=1 by definition.

Code: Select all

```
2.1.0. Position
3 6 5 Chyphers
```

365 = 3 x 102 + 6 x 101 + 5 x 100

In the hexadecimal/sedecimal system, you have 16 digits: 0 to F. The base is 1016. This means, that the 10 here is meant to be a hexadeciaml number, denoted by a subscript 16 in decimal system, as the decimal system is the default. As we don't have enough figures for the sixteen digits/cyphers in the sedecimal system (as the default system only has ten cyphers), we use letters for the numbers 10 to 15: A=10, B=11, C=12, D=13, E=14, and F=15. For representing the base, we need to use the two digits, 1 and 0 as the string '10' in the hexadecimal system means 1 x 16 + 0. Consider the hexadecimal number 16D = 1 x 10162 + 6 x 10161 + D x 10160. Using the decimal system, 16D = 1 x 162 + 6 x 161 + 13 x 160:

1 x 162= 1 x 16 x 16 = 256

6 x 161 = 6 x 16 = 96

D x 160 = 13 x 1 = 13

256 + 96 + 13 = 365

In the octal system, you have just 8 digits: 0 to 7. The base is 108. This means, the base is given in the octal system, denoted by a subscript 8. The number 36510 is 5558:

5 x 82 + 5 x 81 + 5 x 80 = 5 x 64 + 5 x 8 + 5 x 1 = 320 + 40 + 5 = 365

Similar, in the binary system, there are just two digits: 0 and 1. Consider the binary number 101101101, which again is 365 in the decimal system:

1011011012

= 1 x 28 + 0 x 27 + 1 x 26 + 1 x 25 + 0 x 24 + 1 x 23 + 1 x 22 + 0 x 21 + 1 x 20

= 1 x 256 + 0 x 128 + 1 x 64 + 1 x 32 + 0 x 16 + 1 x 8 + 1 x 4 + 0 x 2 + 1 x 1

= 256 + 64 + 32 + 8 + 4 + 1

= 365

Note, that in every place-value system, the base of the system is denoted '10' in that very system, respectively:

Code: Select all

```
Hexadecimal: F+1 = 10
Decimal: 9+1 = 10
Octal: 7+1 = 10
Binary/Dual: 1+1 = 10
```

Hope this helps!

My neurochemistry has fucked my impulse control, now I'm diagnosed OOD = oppositional opinion disorder, one of the most deadly diseases in totalitarian states, but can be cured in the free world.

- eldin raigmore
- korean
**Posts:**6375**Joined:**14 Aug 2010 19:38**Location:**SouthEast Michigan

### Re: Octal numbering system

Normally the base is written out as a word in the orthography of your meta-language.

For instance we’d say “base ten” not “base 10”.

And 10ten not 1010.

In decimal, 365ten is 3 times ten-squared, plus 6 times ten, plus 5.

In octal, 555eight is 5 times eight-squared, plus 5 times eight, plus 5.

In decimal that translates as 5 times sixty-four plus 5 times eight plus 5;

in other words three-hundred-twenty plus forty plus 5, or 320ten + 40ten + 5ten,

or 365ten.

In octal, 365eight is 3 times eight-squared plus 6 times eight plus 5.

In decimal, that’s 3 times sixty-four, plus 6 times eight, plus 5;

or 192ten + 48ten + 5ten,

or 245ten.

—————

The most popular main bases in the numeral systems of natural languages with multiplicative bases for their numeral systems, are ten and twenty (according to WALS.info); although students of Greenberg also found languages with bases twelve, and five, and four, to be fairly numerous (pardon the expression!).

Mark Rosenberg has, or once had, a list of natural languages with almost each and every whole-number-greater-than-one base from three up to about seventy-six or seventy-eight IIANM; although as the WALS.info text points out, most numeral systems with a

WALS also points out that, in every language in their sample with a base of twenty or more, and in several with a base lower than twenty, there is a “sub-base”. For instance a language whose main base is twenty might have a sub-base of five; or a language whose main base is twelve might have a sub-base of four.

They also point out that languages frequently have a super-base which is a multiple of, but often not a power of, their main base.

For instance, languages with main base twenty, frequently have a next-higher base of one-hundred or two-hundred, rather than the square of twenty (four-hundred).

Or, maybe a language’s main base is twenty, and its subbase is five and its superbase is three-hundred-sixty.

Or its main base is twelve, its subbase is four, and its superbase is one-hundred-twenty.

———

Some natural languages’ numeral systems have a series of bases, each of which is a multiple of the next smaller base (if there is a smaller base), and a divisor of the next larger base (if there is a larger base). Often, after a certain base, the remaining bases are the consecutive powers of one of the earlier bases.

For instance, in English, the bases are:

ten, hundred, thousand, million, billion, trillion, quadrillion, quintillion, ..., centillion.

Past thousand, they’re the consecutive powers of thousand, out to the hundred-first power (centillion = thousand^101).

———

BTW. Oct 31 and Nov 27 and Dec 25 are all the same number.

That is, 31eight = 27nine = 25ten.

For instance we’d say “base ten” not “base 10”.

And 10ten not 1010.

In decimal, 365ten is 3 times ten-squared, plus 6 times ten, plus 5.

In octal, 555eight is 5 times eight-squared, plus 5 times eight, plus 5.

In decimal that translates as 5 times sixty-four plus 5 times eight plus 5;

in other words three-hundred-twenty plus forty plus 5, or 320ten + 40ten + 5ten,

or 365ten.

In octal, 365eight is 3 times eight-squared plus 6 times eight plus 5.

In decimal, that’s 3 times sixty-four, plus 6 times eight, plus 5;

or 192ten + 48ten + 5ten,

or 245ten.

—————

The most popular main bases in the numeral systems of natural languages with multiplicative bases for their numeral systems, are ten and twenty (according to WALS.info); although students of Greenberg also found languages with bases twelve, and five, and four, to be fairly numerous (pardon the expression!).

Mark Rosenberg has, or once had, a list of natural languages with almost each and every whole-number-greater-than-one base from three up to about seventy-six or seventy-eight IIANM; although as the WALS.info text points out, most numeral systems with a

*multiplicative*base, use a main base that’s twenty or less.WALS also points out that, in every language in their sample with a base of twenty or more, and in several with a base lower than twenty, there is a “sub-base”. For instance a language whose main base is twenty might have a sub-base of five; or a language whose main base is twelve might have a sub-base of four.

They also point out that languages frequently have a super-base which is a multiple of, but often not a power of, their main base.

For instance, languages with main base twenty, frequently have a next-higher base of one-hundred or two-hundred, rather than the square of twenty (four-hundred).

Or, maybe a language’s main base is twenty, and its subbase is five and its superbase is three-hundred-sixty.

Or its main base is twelve, its subbase is four, and its superbase is one-hundred-twenty.

———

Some natural languages’ numeral systems have a series of bases, each of which is a multiple of the next smaller base (if there is a smaller base), and a divisor of the next larger base (if there is a larger base). Often, after a certain base, the remaining bases are the consecutive powers of one of the earlier bases.

For instance, in English, the bases are:

ten, hundred, thousand, million, billion, trillion, quadrillion, quintillion, ..., centillion.

Past thousand, they’re the consecutive powers of thousand, out to the hundred-first power (centillion = thousand^101).

———

BTW. Oct 31 and Nov 27 and Dec 25 are all the same number.

That is, 31eight = 27nine = 25ten.

My minicity is http://gonabebig1day.myminicity.com/xml

### Re: Octal numbering system

Never seen this anywhere. My textbooks only had 1010.eldin raigmore wrote: ↑15 Aug 2019 09:08Normally the base is written out as a word in the orthography of your meta-language.

For instance we’d say “base ten” not “base 10”.

And 10ten not 1010. ...

My neurochemistry has fucked my impulse control, now I'm diagnosed OOD = oppositional opinion disorder, one of the most deadly diseases in totalitarian states, but can be cured in the free world.

### Re: Octal numbering system

Haha, no, but definitely unique.

It's one of the most helpful posts I've seen in a great while. Thank you very much.

### Re: Octal numbering system

Here is a little Turbo Pascal program doing decimal to octal and octal to decimal conversion:

The program consists of two functions, DezOct and OctDez. DezOct performs conversion of an integer (which here is a string of 15 bits and a sign bit) to a string of octal cyphers represented by the type numberstring. OctDez takes a numberstring consisting of cyphers '0' to '7' of type Char and converts it to a decimal number represented by an Integer value. The Writeln command does a screen output in a way that you easily can check whether the conversion is correct or not.

Function DezOct:

First, s is initialized to the empty string. The local variable r is set to the the value v passed to the function. In the REPEAT UNTIL loop the quotient q and the reminder r of r are computed by integer division and modulo operations. At the beginning of the loop, r equals v. By adding the value Ord('0') to r, we get the ASCII value of the reminder, which is then turned into a character and added to the output string s. In the first loop, after the modulo operation, this character is on the least significant position of the octal result string. By assigning q to r, we assure that r decreases and the algorthm eventually terminates in one of the following loops.

Function OctDez:

In this function, v (value) serves a similar purpose like s in DezOct, while i is an index running from 0 to the length of the passed argument in s (string). Both variables are initialized with zero. If the passed argument would be an empty string, i would be equal to the length of an empty string, which is zero. The loop would then be skipped and the zero value in v would then be passed to the calling routine. Otherwise, i is incremented and the i-th position (which is the first position during the first loop) of string s is accessed. By subtracting Ord('0') from the ordinal number of the accessed character of s, in c, we'll get a number within the range 0 and 7, with borders included. These are exactly the cyphers of the octal system. As v is zero in the first lap, we just add c. Remember that the last term of our general formular was ... + d0 x b0. As b0 equals 1 we have just d0 added, just like in the algorithm. In each lap, the v of the last lap is multiplied by the base and the value of the cypher of the current lap added. The result is then assigned to v, to be multiplied by the base in the next lap.

You can translate it to your favorite programming language. Or you can use either Turbo Pascal 3 for PC (if it is still available) or download

an MSX emulator here. If you contact me, I can mail you a TP3 version running on that emulater. MSX is a Z80 based homecomputer system. It makes still sense to me to use systems like MSX for the kind of purpose discussed here.

Code: Select all

```
(* oct dec conversion 16.08.2019 *)
TYPE numberstring = STRING[14];
FUNCTION DezOct ( v : Integer ) : numberstring ;
VAR q : Integer; (* quotient *)
VAR r : Integer; (* remainder *)
VAR s : numberstring;
BEGIN (* DezOct *)
s:='';
r:=v;
REPEAT
q := r DIV 8 ;
r := r MOD 8 ;
s := Chr(Ord('0')+r)+s;
r := q;
UNTIL r=0 ;
DezOct:=s;
END; (* DezOct *)
FUNCTION OctDez ( s : numberstring ) : Integer ;
VAR v : Integer;
VAR i : Integer;
VAR c : Integer;
BEGIN (* OctDez *)
v:=0;
i:=0;
WHILE i<Length(s)
DO BEGIN
i := i+1 ;
c := Ord(s[i])-Ord('0');
v := v * 8 + c ;
END;
OctDez:=v;
END; (* OctDez *)
VAR o : numberstring; (* octal *)
VAR d : Integer; (* decimal *)
VAR i : Integer; (* index *)
BEGIN (* odc *)
ClrScr;
FOR i:=0 TO 21
DO BEGIN
o:=DezOct(i);
d:=OctDez(o);
Writeln
(
' dec: ',i:2,
' oct: ',o:2,
' dec: ',d:2
);
END;
END. (* odc *)
```

Function DezOct:

First, s is initialized to the empty string. The local variable r is set to the the value v passed to the function. In the REPEAT UNTIL loop the quotient q and the reminder r of r are computed by integer division and modulo operations. At the beginning of the loop, r equals v. By adding the value Ord('0') to r, we get the ASCII value of the reminder, which is then turned into a character and added to the output string s. In the first loop, after the modulo operation, this character is on the least significant position of the octal result string. By assigning q to r, we assure that r decreases and the algorthm eventually terminates in one of the following loops.

Function OctDez:

In this function, v (value) serves a similar purpose like s in DezOct, while i is an index running from 0 to the length of the passed argument in s (string). Both variables are initialized with zero. If the passed argument would be an empty string, i would be equal to the length of an empty string, which is zero. The loop would then be skipped and the zero value in v would then be passed to the calling routine. Otherwise, i is incremented and the i-th position (which is the first position during the first loop) of string s is accessed. By subtracting Ord('0') from the ordinal number of the accessed character of s, in c, we'll get a number within the range 0 and 7, with borders included. These are exactly the cyphers of the octal system. As v is zero in the first lap, we just add c. Remember that the last term of our general formular was ... + d0 x b0. As b0 equals 1 we have just d0 added, just like in the algorithm. In each lap, the v of the last lap is multiplied by the base and the value of the cypher of the current lap added. The result is then assigned to v, to be multiplied by the base in the next lap.

You can translate it to your favorite programming language. Or you can use either Turbo Pascal 3 for PC (if it is still available) or download

an MSX emulator here. If you contact me, I can mail you a TP3 version running on that emulater. MSX is a Z80 based homecomputer system. It makes still sense to me to use systems like MSX for the kind of purpose discussed here.

My neurochemistry has fucked my impulse control, now I'm diagnosed OOD = oppositional opinion disorder, one of the most deadly diseases in totalitarian states, but can be cured in the free world.

### Re: Octal numbering system

and there are dedicated functions dec2oct and oct2dec in all spreadsheets...

(You can also use an octal system to name numbers, while using a decimal numeric representation to compute...)

(You can also use an octal system to name numbers, while using a decimal numeric representation to compute...)