Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including nonary with all npm packages installed. Try it out:

var nonary = require("nonary")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

nonary v1.0.0

base 9 / base 3 conversions

nonary

Base 9, nonary, conversions, to/from balanced ternary (2-trit groups) and integers

Usage:

var nonary2n = require('nonary').nonary2n;
var n2nonary = require('nonary').n2nonary;
var nonary2bts = require('nonary').nonary2bts;
var bts2nonary = require('nonary').bts2nonary;

n2nonary(-29524);   // 'zzzzz'
nonary2n('zzzzz');  // -29524

bts2nonary('iiiiii111100');   // 'zzzdd0'
nonary2bts('zzzdd0');         // 'iiiiii111100'

Digit values 0, +1, +2, +3, +4, -1, -2, -3, and -4 correspond to nonary digits a, b, c, d, 0, w, x, y, and z, and balanced ternary 00, 01, 1i, 10, 11, 0i, i1, i0, and ii.

Currently supports balanced nonary only (-4 to +4).

Analogous to octal (base 8) for binary, where each octal digit represents 3 bits; each nonary (base 9) digit represents 2 trits. Compact representation for balanced-ternary.

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free