Questions tagged [ternary-representation]

The base-3 positional numeral system which represents numbers using the digits 0, 1, and 2

Ternary is the base-3 positional numeral system which represents numbers using the digits 0, 1, and 2. In computing it is less common than , but there have been ternary computers, and it can be used to represent sequences of ternary (3-way) choices.

A unit of information in the ternary numeral system is sometimes called a trit (by analogy with for binary).

Number systems:

       Name         |   Base  |   numbers
------------------------------------------                 
ternary   - system  |     2   |    0... 2
decimal   - system  |    10   |    0... 9

ternary    |    decimal      
-----------------------
         0 |        0        
         1 |        1         
         2 |        2       
        10 |        3        
        11 |        4      
        12 |        5       
        20 |        6      
        21 |        7       
        22 |        8       
        30 |        9      
       101 |       10       
       121 |       16      
      1012 |       32       
      2101 |       64       
     11202 |      128     
    100110 |      255      

Decimal -> Ternary

Number: 42

42 / 3 = 14 Rest 0    ^
14 / 3 =  4 Rest 2    |
 4 / 3 =  1 Rest 1    |
 1 / 3 =  0 Rest 1    |  => 42 = 1120
                                 ----->

Ternary -> Decimal

Number: 1120

1  1  2  0   
|  |  |   -------- 0 x 3^0  ->   0
|  |   ----------- 2 x 3^1  ->   6
|   -------------- 1 x 3^2  ->   9
 ----------------- 1 x 3^3  ->   27
                                    = 42
11 questions
89
votes
15 answers

Why binary and not ternary computing?

Isn't a three state object immedately capable of holding more information and handling larger values? I know that processors currently use massive nets of XOR gates and that would need to be reworked. Since we are at 64 bit (we can represent 2^63…
ojblass
  • 21,146
  • 22
  • 83
  • 132
8
votes
9 answers

Binary to ternary representation conversion

Does anybody know (or may point to some source to read about) a method or algorithm to convert a number represented in binary numeral system into the ternary one (my particular case), or universal algorithm for such conversions? The solution I've…
4
votes
2 answers

Convert decimal to balanced Heptavintimal

I'm trying to make a function to convert decimal to balanced Heptavintimal (0123456789ABCDEFGHKMNPRTVXZ) where 0 represent -13, D : 0 and Z 13 I have tried this but some cases are not working properly: static const std::string HEPT_CHARS =…
Jeremy Talus
  • 125
  • 2
  • 11
3
votes
9 answers

How is 6 trits equal to 9.5 bits?

This reddit thread says 6 trits ~ 9.5 bits. How is 6 trits ~ 9.5 bits?
Lazer
  • 90,700
  • 113
  • 281
  • 364
3
votes
4 answers

Conversion of binary bitstream to and from ternary bitstream?

I need to convert arbitary length binary into an exact ternary representation. Ideally, given an array of bits char buffer[n], the algorithm would be able to produce a array of trits(analog of bits), and vice versa. Is there such an algorithm? I am…
scientiaesthete
  • 919
  • 9
  • 20
1
vote
0 answers

how to find a minimal value of a 9-bit trinary number

I got the following question: A trinary computer uses trits instead of bits (a trit can have values 0, 1 or 2). A trinary computer has a 9-trit floating-point representation of a number. Trit 8, the MST (Most Significant Trit), is the sign trit (1…
xYaelx
  • 144
  • 1
  • 1
  • 11
1
vote
0 answers

Google Foobar Challenge: Peculiar Balance

I'm solving a problem where you convert a base-10 positive integer between 0 and 1000000000 to a balanced ternary form as part of Google's code challenge. It seems to work for various cases I've tested under the constraint, but it fails tests 4 and…
laketuna
  • 3,832
  • 14
  • 59
  • 104
1
vote
1 answer

Ternary Plot Heat Map Gnuplot

I have 4 columns of data: a:b:c:t I want a b c to be the coordinates on my ternary plot and then the corresponding t column would provide the 'heat level' of each point. So far I have the code to produce regular ternary plots and my data is in a…
1
vote
0 answers

Ternary search tree in java

I'm basically working on ternary implementation in java .I don't wanna use ajax. I am working on bigram model and so want to autocomplete the next alphabet.Can anyone suggest how to implement ??? Thnks
Misha
  • 685
  • 8
  • 20
0
votes
2 answers

Number of trits matching count criteria

For all trinary numbers with length 36 (including those starting with 0's), how many have exactly equal counts of 1's and 2's, or exactly one more 1 than 2? For example: 00 - yes 01 - yes 02 - no 10 - yes 11 - no 12 - yes 20 - no 21 - yes 22 -…
ChrisInEdmonton
  • 4,470
  • 5
  • 33
  • 48
0
votes
2 answers

Ternary Numbers, regex

I'm looking for some regex/automata help. I'm limited to + or the Kleene Star. Parsing through a string representing a ternary number (like binary, just 3), I need to be able to know if the result is 1-less than a multiple of 4. So, for example 120…
K-man
  • 353
  • 1
  • 13