2007/6/3, Geoff Canyon write:
As an aside, one interesting aspect of negative bases is that you
never need to negate a number. For example, -7 = 1202.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
The same aspect is true for an other ternary number system too. It
called *balanced
ternary*, because it use the _1 0 1 digits, but its basis is +3. Instead of
_1 should be write 2. Knuth call this number system "perhaps *the
prettiest*one". For example, -7 = 212 = (_1*3^2)+(1*3^1)+(_1*3^0).
This system may be generalize two, three or four dimensional domain too.
Here is a little 3D example and the conversation verbs.
__________________
|\ \ \
\
|
\_____\_____\_____\
| | | |
|
\|3 1 0|4 1 0|5 1 0|
\_____|_____|_____|
| | |
|\|4 2 0|
| \_____|
| | |
|\|4 3 0|
| \_____|
______ | | |
|\ \ |\|4 4 0|
| \_____\ | \_____|
| | |___| | |
|\|2 5 0| \|4 5 0|
| \_____|_____\_____|
| | | | |
\|2 6 0|3 6 0|4 6 0|
\_____|_____|_____|
__________________
|\ \ \
\
|
\_____\_____\_____\
| | | |
|
\| AC | AD | ABE |
\_____|_____|_____|
| | |
|\| DG |
| \_____|
| | |
|\| DA |
| \_____|
______ | | |
|\ \ |\| DD |
| \_____\ | \_____|
| | |___| | |
|\| CGH | \| CGG |
| \_____|_____\_____|
| | | | |
\| CGB | CGo | CGA |
\_____|_____|_____|
vabc NB. veactorial alphabet = 27 digits
oABCDEFGHIJKLMNOPQRSTUVWXYZ
(,.' ';,.'xyz'),.(<"0 vabc),:,.&.><"1 xyz=:decivek"0 vabc
┌─┬─┬─┬──┬─┬─┬──┬──┬──┬──┬─┬─┬──┬─┬─┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┐
│ │o│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│
├─┼─┼─┼──┼─┼─┼──┼──┼──┼──┼─┼─┼──┼─┼─┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┤
│x│0│1│_1│0│1│_1│ 0│ 1│_1│0│1│_1│0│1│_1│ 0│ 1│_1│ 0│ 1│_1│ 0│ 1│_1│ 0│ 1│_1│
│y│0│0│ 0│1│1│ 1│_1│_1│_1│0│0│ 0│1│1│ 1│_1│_1│_1│ 0│ 0│ 0│ 1│ 1│ 1│_1│_1│_1│
│z│0│0│ 0│0│0│ 0│ 0│ 0│ 0│1│1│ 1│1│1│ 1│ 1│ 1│ 1│_1│_1│_1│_1│_1│_1│_1│_1│_1│
└─┴─┴─┴──┴─┴─┴──┴──┴──┴──┴─┴─┴──┴─┴─┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┘
decivek=:3 :'3#.|.|:j-3*2=j=.3 3 3x#:,,.vabc i.y'
,alfavek"1 xyz
oABCDEFGHIJKLMNOPQRSTUVWXYZ
Basis of number system = +3.
]XYZ0=:alfavek &.>;/KJ0
┌──┬──┬───┬──┬──┬──┬───┬───┬───┬───┬───┐
│AC│AD│ABE│DG│DA│DD│CGG│CGA│CGB│CGo│CGH│
└──┴──┴───┴──┴──┴──┴───┴───┴───┴───┴───┘
|:(,.XYZ0) ,.;/KJ0
┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐
│ AC│ AD│ ABE│ DG│ DA│ DD│ CGG│ CGA│ CGB│ CGo│ CGH│
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│3 1 0│4 1 0│5 1 0│4 2 0│4 3 0│4 4 0│4 5 0│4 6 0│2 6 0│3 6 0│2 5 0│
└─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘
>decivek &.>XYZ0
3 1 0
4 1 0 o--------------> +x
5 1 0 |\
4 2 0 | \
4 3 0 | \
4 4 0 | \
4 5 0 | \
4 6 0 | +z
2 6 0 |
3 6 0 V
2 5 0
KJ0 -: >decivek &.>XYZ0 +y
1
By means of this number system "coordinateless" vector arithmetical
operations may be developping.
regards,
istvan
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm