Nocturnally Psychologizing Millipede
    Wondering what’s next for npm?Check out our public roadmap! »

    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

    2

    Version

    1.0.0

    License

    MIT

    Last publish

    Collaborators

    • avatar