Duodecimal numbers

Duodecimal numbers

Go to

Home Page

English Pages

Road map

Backward

Italian


Preface
Preface
Addition
Addition
Multiplication
Multiplication

Preface

Whoever knows some programming will have no problems to work with numerical systems in base different from 10. For instance, programmers use three different numerical systems. The first one is in base 2, or binary, and it is used at lower levels, as for instance when designing logical circuits or defining new physical protocols of communication. The second one is in base 8. It allows to operate more quickly on the binary numbers and it is very useful with protocols of high level like transport protocols, which use mostly octets. At last, that one in base 16, used in the high level representations of data flows, memory addresses, character sets and so forth.

In the everyday life instead, we use the decimal system even if in few countries, as for instance the United States of America, people still use old measurement systems that sink their origins in the middle age and beyond, like miles, feet, ounces, pounds and so on. In England, some time ago, people still used a system based on 12 for money. By the way, eggs are still sold by dozens and 24 is the number of the hours in one day, even if then the system of measure of time is based on sixthieths (60).

Honestly, the only valid reason for using the decimal system is that we have ten fingers, if we just consider hands, so that it is natural to use such a system even if, as we will see, is not surely the best one.

In fact, 10 could be divided only by 2 and by 5. Therefore there are limits to the possibility to divide a number to suit any need. Vice versa 12 could be divided by 2, 3, 4, and 6, so that a system founded on such a base will result more comfortable when large numbers has to be rendered, because of two additional digits. Obviously it is necessary to learn from scratch a new tables for additions and multiplications. However, as it could be seen in the two specific sections, those tables are quite simpler than those in base 10. Particularly, the columns of 2, 3, 4, 6, 8 and 10 are very simple to learn in base 12. Only that one of 5, 7 and 9 are a little bit more complicated to remember. Vice versa in the decimal system the simple columns are those of 2 and 5. The others should be learnt very well by hearth.

For the digit corresponding to 10 I have chosen the X letter, since in Roman numbers 10 is written by X and his shape differs sufficiently from those of the 9 digits of the decimal system. Similarly I has chosen the H letter for 11, still because its shape is quite distinguishable from that one of the other symbols and because it looks like two '1' placed side by side and joined by a horizontal hyphen. Therefore, the twelve resulting digits, including zero, are:

0 1 2 3 4 5 6 7 8 9 X H


I developed a simple REXX macro to calculate the addition and multiplication tables for base 12 numbers. You need to install a REXX interpreter to execute it. It can be run on any operating system where such interpreter is available.

Download macro

Here is the source listing:

/* REXX                          */
/* Author:  Dario de Judicibus   */
/* Address: dario@dejudicibus.it */
/* Created: 13 May 2003          */
/* Version: 1.0.0                */

parse arg op

if op = '' | op = '?' | op = '/?' | op = '-?' | op = '/h' | op = '-h' then do
  say "SYNTAX"
  say "  base12 [?|operation]"
  say "    operation = [+|*]"
  say ""
  say "PURPOSE"
  say "  Display the addition or multiplication table"
  say "  for base 12 numbers" 
  exit 
end

if op = '+' then do
  call sayhead op
  call sayadd
end
else if op = '*' then do
  call sayhead op
  call saymult
end
else
  say "Unknow operation" op 

exit

sayadd: procedure
  do i = 1 to 12
    s = right(10to12(i),3) || '|' 
    do j = 1 to 12
      k = i + j
      s = s || '|' || right(10to12(k),3)
    end
    say s  
  end
return

saymult: procedure
  do i = 1 to 12
    s = right(10to12(i),3) || '|' 
    do j = 1 to 12
      k = i * j
      s = s || '|' || right(10to12(k),3)
    end
    say s  
  end
return

sayhead: procedure
  parse arg ochar .
  s = right(ochar,3) || '|' 
  do j = 1 to 12
    s = s || '|' || right(10to12(j),3)
  end
  say s
  say left('',length(s),'-')
return

10to12: procedure
  arg n10 .
  n12 = ''
  i10 = n10 ; 
  f10 = n10 ;
  do while i10 <> 0
    f10 = i10 // 12 ; 
    i10 = i10 % 12 ;
    if f10 < 10 then 
      d12 = f10
    else if f10 = 10 then 
      d12 = 'X'
    else if f10 = 11 then 
      d12 = 'H'
    else
      d12 = '?'
    n12 = d12 || n12 ;
  end

return n12 ;

Dario de Judicibus © 1997-2009