Ternary algorithms

Balanced Ternary Numeral System - forum was moved from http://ternary.info

Moderator: haqreu

eudoxie
Maniac
Posts: 277
Joined: 17 Sep 2012 13:36
Location: 81.170.128.52

Ternary algorithms

Post by eudoxie »

In Tunguska I've been "cheating" and using the native system to calculate most arithmetic operations.

So, to calculate %1A0 + %002, for an instance, I would convert the two numbers to binary (72 and 2), compute the result with C++'s + operator, and then convert back to ternary.

The ternary->binary conversion is very quick, but the binary->ternary algorithm is quite bulky. So I'm wondering if there are any established algorithms for ternary arithmetics (mainly addition, multiplication, division, and modulo)

Of course, I could probably get to it and make my own algorithms, but that feels an awful lot like re-inventing the wheel.
User avatar
Shaos
Admin
Posts: 24008
Joined: 08 Jan 2003 23:22
Location: Silicon Valley

Re: Ternary algorithms

Post by Shaos »

Fast ternary division by 2,4,8,10:
http://www.dyalog.dk/dfnsdws/n_JitSub.htm
http://dfns.dyalog.com/n_JitSub.htm
User avatar
Shaos
Admin
Posts: 24008
Joined: 08 Jan 2003 23:22
Location: Silicon Valley

Post by Shaos »

web-site is not available anymore :(
Я тут за главного - если что шлите мыло на me собака shaos точка net
User avatar
Shaos
Admin
Posts: 24008
Joined: 08 Jan 2003 23:22
Location: Silicon Valley

Re:

Post by Shaos »

Shaos wrote:web-site is not available anymore :(
changed link above to working one
Я тут за главного - если что шлите мыло на me собака shaos точка net