ErasedSoul's blog

By ErasedSoul, history, 5 years ago, In English

Hello everyone, How to represent negative numbers in balanced ternary?

  • Vote: I like it
  • +3
  • Vote: I do not like it

| Write comment?
»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Taken from https://cp-algorithms.com/algebra/balanced-ternary.html (I don't know if it is the formal one).

Suppose you have a negative number x, find the smallest non-negative k such that $$$3^k \geq -x$$$, then $$$3^k+x \geq 0$$$. The corresponding representation is $$$(-1)$$$$$$($$$representation of $$$3^k+x$$$$$$)$$$. For instance $$$x=-17=-27+10$$$, then its representation is $$$(-1)(101)$$$

Remark: $$$()$$$ for illustration only