Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript. Learn more »

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

install

npm i balanced-ternary

Downloadsweekly downloads

1

version

1.0.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability