algorithm - How to convert from unbalanced to balanced ternary? -
algorithm - How to convert from unbalanced to balanced ternary? -
my goal convert decimal number balanced ternary. converting decimal unbalanced ternary requires partition 3 , keeping track of remainders. 1 time have unbalanced ternary representation of number can't seem figure out how "balance" it.
for example: 15 in decimal 120 in unbalanced ternary , +--0 in balanced ternary. how go 120 +--0? can't figure out how deal 2s in unbalanced ternary representation.
thank you!
note 2 in ternary +- in balanced ternary, or in decimal 2 = 3 - 1. if start array filled 0s, 1s, , 2s, replace every 2 -1 , add together 1 number left. (make sure have 0 @ origin of number, @ to the lowest degree if starts 2.) depending on how replacement may need replace 3s 0s, adding 1 left usual. repeat process until there no more 2s (or 3s).
algorithm math ternary
Comments
Post a Comment