balanced-ternary

1.0.0 • Public • Published

balanced-ternary

Convert balanced ternary strings to/from signed integers

Usage:

var bts2n = require('balanced-ternary').bts2n;
var n2bts = require('balanced-ternary').n2bts;

bts2n('10i');   // 8
n2bts(8);       // '10i'

bts2n(s) converts from balanced ternary string to signed integer, n2bts(n) converts from signed integer to balanced ternary string.

Digits 1, 0, and i correspond to +1, 0, and -1.

Reference: Balanced ternary on Wikipedia

Package Sidebar

Install

npm i balanced-ternary

Weekly Downloads

1

Version

1.0.0

License

MIT

Last publish

Collaborators

  • thirdcoder