Блог пользователя ErasedSoul

Автор ErasedSoul, история, 4 года назад, По-английски

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

  • Проголосовать: нравится
  • +3
  • Проголосовать: не нравится

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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