getset.js
function get_trit(n,i) {
  // convert entire number to balanced ternary string then slice
  // would be nice to extract without converting everything, see extract_digit(), which
  // works for unbalanced ternary, but balanced converts 2 -> 1i, so individual digit extraction
  // is more difficult -- see https://en.wikipedia.org/wiki/Balanced_ternary#Conversion_from_ternary
  var s = n2bts(n);
  return ~~BT_DIGIT_TO_N[s.charAt(s.length - i - 1)];
}
function get_trit(n,i) {
  // convert entire number to balanced ternary string then slice
  // would be nice to extract without converting everything, see extract_digit(), which
  // works for unbalanced ternary, but balanced converts 2 -> 1i, so individual digit extraction
  // is more difficult -- see https://en.wikipedia.org/wiki/Balanced_ternary#Conversion_from_ternary
  var s = n2bts(n);
  return ~~BT_DIGIT_TO_N[s.charAt(s.length - i - 1)];
}
function get_trit ( n , i ) { // convert entire number to balanced ternary string then slice // would be nice to extract without converting everything, see extract_digit(), which // works for unbalanced ternary, but balanced converts 2 -> 1i, so individual digit extraction // is more difficult -- see https://en.wikipedia.org/wiki/Balanced_ternary#Conversion_from_ternary var s = n2bts ( n ) ; return ~ ~ BT_DIGIT_TO_N [ s . charAt ( s . length - i - 1 ) ] ; }
get trit value at ith index of n, i of 0=least significant
get trit value at ith index of n i of 0 = least significant