Balanced Ternary Converter

Decimal and balanced ternary, step by step.

  • No minus sign needed
  • Exact fractions
  • Addition with carries
Rows of soft clay beads in three sizes, each row balanced across a smooth clay beam on a small rounded clay table in daylight.

The guide

Three digits, no minus sign: how balanced ternary writes every whole number

Balanced ternary uses the digits -1, 0 and 1 in base 3. Every whole number gets a string with no minus sign, and one small carry rule explains the whole system.

  • 11T01 100 written in balanced ternary: 81 + 27 - 9 + 1
  • 121 largest number that five trits can write
  • 364 largest number that six trits can write
  • 1.585 bits of information in one trit (about)
  • 18 trits length of one word on the Setun computer
Read the full guide Fold the guide 8 min · 11 sources

Picture a shop scale with two pans and five weights: 1, 3, 9, 27 and 81. You may put a weight on either pan, or leave it off the scale. The Wikipedia article on balanced ternary gives a 60 gram example for exactly this kind of scale. Put the 81 and the 9 in the pan opposite the object, put the 27 and the 3 beside the object, and leave the 1 on the table. The scale balances. The same article has a coin version: if buyer and seller each hold one coin worth 1, 3, 9, 27 and 81, every price up to 121 can be settled.

Each weight has three choices: opposite pan, same pan or off. Those three choices are the three digits of balanced ternary. That is the whole idea, and the rest is bookkeeping.

Three digits that already carry the sign

Ordinary base 3 uses the digits 0, 1 and 2. Balanced ternary keeps base 3 but swaps the digit set for -1, 0 and 1. The article on the system calls it a balanced signed-digit representation, and it states two consequences straight away. Every integer can be written without a separate minus sign, and the leading non-zero digit has the sign of the number itself.

Because -1 is awkward to type inside a string, the article writes it as T, which it describes as resembling a ligature of the minus sign and 1. Other conventions use the plain signs - and +, or the Greek letter theta. This tool reads T, 0 and 1, and also accepts - and + for T and 1.

The positions are powers of 3, just as decimal positions are powers of 10. The article lists a few values: 5 is 1TT, which means 9 - 3 - 1. Eight is 10T, which means 9 - 1. Minus nine is T00. Minus five is T11. Compare the last two lines: T11 is 1TT with every digit flipped.

That flipping is the second useful property. To negate any balanced ternary number, swap T and 1 and leave the zeros alone. The article on ternary computers makes the same point as an argument for using the system: subtraction becomes inverting the digits and then adding normally, and a negative value needs no leading minus sign.

How many trits does a number need? One trit reaches 1. Two trits reach 4, which is 11. Three reach 13, then 40, then 121, then 364. The OEIS entry A003462 lists these as (3^k - 1) / 2, the value of a string of k ones. So 364 is the largest number six trits can write, and a number that is larger needs a seventh. One thousand needs seven, since it is above 364 and below 1,093.

The carry that fixes a remainder of 2

To convert a number to balanced ternary, divide by 3 and look at the remainder. A remainder of 0 or 1 is already a legal digit. A remainder of 2 is not, because 2 is not in the digit set. The fix is a single identity: 3q + 2 equals 3(q + 1) - 1. So write T for the digit and add 1 to the quotient before the next division. That added 1 is the carry.

Take 100. Divide by 3: 100 is 3 times 33 plus 1, so the first trit is 1. Next 33 is 3 times 11 plus 0, so the trit is 0. Then 11 is 3 times 3 plus 2. This is the case that needs the carry: the trit is T and the quotient becomes 4, not 3. Then 4 is 3 times 1 plus 1, trit 1, and finally 1 gives trit 1.

Read the trits from last to first and you get 11T01. Check it by writing out the place values: 81 + 27 - 9 + 0 + 1 comes to 100. The converter on this page does this check on every result, converting back by multiplying out the places, and it refuses to call a conversion done if the two directions disagree.

The divide-and-carry steps are derived here rather than copied from a source. What the sources supply is the definition of the system and the table of small values. That is enough to test the method. The tool’s output for 5, 8, 9, -5 and -9 matches the article’s tables, and an independent enumeration of every string of up to nine trits agrees with the tool on every number from -5000 to 5000.

Two facts fall out of the digit set. A whole number is divisible by 3 exactly when its last trit is 0, which the article states. And parity is easy to read: the Wikipedia article on parity says that in an odd base a number is even exactly when the sum of its digits is even. In balanced ternary every non-zero trit is odd, whether it is 1 or -1, so a number is even exactly when it has an even count of non-zero trits. Check 100 again: 11T01 has four non-zero trits, and 100 is even.

Fractions, rounding and the case of one half

Places to the right of the point are negative powers of 3: one third, one ninth, one twenty-seventh. The article gives -2/3 as T.1, which reads as -1 + 1/3. It lists 1/3 as 0.1 exactly, and 1/5 as a repeating block 1TT1 after the point. The page converts a fraction p / q the same way a hand method would. The whole part is the nearest integer. Each later place multiplies the remainder by 3 and takes the nearest of T, 0 and 1. Try 2/5 with six places: the digits are 1, 1, T, T, 1, 1. Written out, 0.11TT11 is 1/3 + 1/9 - 1/27 - 1/81 + 1/243 + 1/729.

Here the system does something decimal cannot. The article credits Donald Knuth with the observation that truncating and rounding are the same operation in balanced ternary. Cut a string off after any place and you have also rounded to that place. The reason, by an argument the tool’s checks rely on, is that the dropped digits can never add up to more than half a unit of the last kept place. So the tool states an error bound it can prove: the written digits are within half a unit in the last place of the exact fraction.

One half is the only wrinkle, and the article is careful about it. The number 1/2 is not exceptional, because it has two equally valid representations: 0.111 and so on, or 1.TTT and so on. Decimal has the same kind of ambiguity: the article notes that 1/10 is 0.1 and also 0.0999 and so on. When a remainder lands exactly on a half, this page picks the string that rounds away from zero, so 1/2 comes out as 1.TTTTTT with six places.

Adding without a borrow, and why anyone built a computer on it

Adding two balanced ternary numbers works column by column like decimal addition. Add the two trits and the carry that came in. Call the total s, which runs from -3 to 3. The digit is ((s + 1) mod 3) - 1, and the carry out is (s - digit) / 3. A total of 2 gives the digit T and carry 1. A total of -2 gives digit 1 and carry T. Totals of 3 and -3 give digit 0 and a carry of 1 or -1.

Try 37 plus -58. The number 37 is 1101, and -58 is T10TT. Line them up over five places, with a leading zero on the shorter one. The lowest places give 0, then T, then 1, then 2 which becomes T with a carry, then the carry lands on the top place and cancels. The result is 0T1T0, which is T1T0 without the leading zero, and that is -27 + 9 - 3, or -21. The base 10 sum of 37 and -58 is also -21.

The Wikipedia article on balanced ternary says the one-digit addition table has only two carries out of nine entries, against three in unbalanced ternary, and that the one-digit multiplication table has none at all. That is part of why signed-digit systems get a look in hardware design: the article on signed-digit representation notes that a signed-digit form can speed up addition by removing chains of dependent carries. It is a general remark about signed-digit systems, not a promise about any one design.

The best known machine is the Setun, developed in 1958 at Moscow State University under Sergei Sobolev and Nikolay Brusentsov. The Setun article calls it the first modern ternary computer. Fifty were built between 1959 and 1965. Its working memory held 81 words of 18 trits each, and the article reports that a binary replacement at the university cost 2.5 times as much. The Wikipedia article on the ternary system adds that early machines such as the Setun defined a tryte, the ternary counterpart of a byte, as six trits.

How much does a trit hold? The ternary numeral system article gives about 1.585 bits, that is log base 2 of 3, which is 1.58496 to five places. The Optimal radix choice article adds that under one cost model, the number of digits times the base, base 3 is asymptotically best. It presents that as one of several ways to define the cost. None of it says balanced ternary beats binary on today’s chips, and this page makes no such claim.

Negative bases solve the sign problem differently. In negadecimal, base -10, the article’s example writes -8163 as 9977 with no minus sign, but the same page notes that this often costs one extra digit and makes arithmetic more complicated. Balanced ternary keeps the sign symmetric instead. The page on negative bases is useful for that contrast, and this tool does not do negative bases.

What the page does and does not do

The MDN page on BigInt starts from Number.MAX_SAFE_INTEGER, 9,007,199,254,740,991, and shows BigInt arithmetic carrying on past it. That is why a 40 digit input converts without losing a trit. MDN also notes that BigInt values cannot be mixed with ordinary numbers in the same operation, so the page converts every input once and works in BigInt throughout. The heavy checks, such as converting every integer from -5000 to 5000 and back or adding every pair from -60 to 60, run in a Web Worker. MDN describes a worker as a script that runs in a background thread separate from the main one, talking to the page by messages. That keeps typing smooth.

The limits are stated plainly. The page reads up to 40 decimal digits, 120 trits, 60 places after the point and 200 characters. A denominator may reach 1,000,000. It does not do floating point, multiplication of balanced numbers, or any other base. For those, the number base converter and the binary calculator elsewhere on the site are the right tools.

Last, a worked check you can reproduce. Type 100 and read 11T01. Swap the direction and type 11T01 back to get 100. Add 37 and -58 and read 0T1T0. Then step k up to 4 in the list of all numbers and count the rows: 81, one for every whole number from -40 to 40, each with a different string of four trits.

Sources

Every source consulted for this guide. Links checked November 10, 2026.

  1. Balanced ternary - Wikipedia Wikipedia (CC BY-SA 4.0)
  2. Negative base - Wikipedia Wikipedia (CC BY-SA 4.0)
  3. Ternary numeral system - Wikipedia Wikipedia (CC BY-SA 4.0)
  4. Setun - Wikipedia Wikipedia (CC BY-SA 4.0)
  5. Ternary computer - Wikipedia Wikipedia (CC BY-SA 4.0)
  6. Signed-digit representation - Wikipedia Wikipedia (CC BY-SA 4.0)
  7. Optimal radix choice - Wikipedia Wikipedia (CC BY-SA 4.0)
  8. Parity (mathematics) - Wikipedia Wikipedia (CC BY-SA 4.0)
  9. A003462 - OEIS The On-Line Encyclopedia of Integer Sequences (CC BY-SA 4.0)
  10. BigInt - JavaScript | MDN MDN Web Docs (CC BY-SA 2.5 or later)
  11. Web Workers API - Web APIs | MDN MDN Web Docs (CC BY-SA 2.5 or later)