index.js
// (protected) set from string and radix
(protected) set from string and radix
( protected ) set from string and radix
function bnpFromString(s, b)
{
  var k;
  if (b == 16) k = 4;
  else if (b == 8) k = 3;
  else if (b == 256) k = 8; 
  else if (b == 2) k = 1;
  else if (b == 32) k = 5;
  else if (b == 4) k = 2;
  else
  {
    this.fromRadix(s, b);
    return;
  }
  this.t = 0;
  this.s = 0;
  var i = s.length,
    mi = false,
    sh = 0;
  while (--i >= 0)
  {
    var x = (k == 8) ? s[i] & 0xff : intAt(s, i);
    if (x < 0)
    {
      if (s.charAt(i) == "-") mi = true;
      continue;
    }
    mi = false;
    if (sh == 0) this[this.t++] = x;
    else if (sh + k > this.DB)
    {
      this[this.t - 1] |= (x & ((1 << (this.DB - sh)) - 1)) << sh;
      this[this.t++] = (x >> (this.DB - sh));
    }
    else this[this.t - 1] |= x << sh;
    sh += k;
    if (sh >= this.DB) sh -= this.DB;
  }
  if (k == 8 && (s[0] & 0x80) != 0)
  {
    this.s = -1;
    if (sh > 0) this[this.t - 1] |= ((1 << (this.DB - sh)) - 1) << sh;
  }
  this.clamp();
  if (mi) Int128.ZERO.subTo(this, this);
}
function bnpFromString ( s , b ) { var k ; if ( b == 16 ) k = 4 ; else if ( b == 8 ) k = 3 ; else if ( b == 256 ) k = 8 ; else if ( b == 2 ) k = 1 ; else if ( b == 32 ) k = 5 ; else if ( b == 4 ) k = 2 ; else { this . fromRadix ( s , b ) ; return ; } this . t = 0 ; this . s = 0 ; var i = s . length , mi = false , sh = 0 ; while ( -- i >= 0 ) { var x = ( k == 8 ) ? s [ i ] & 0xff : intAt ( s , i ) ; if ( x < 0 ) { if ( s . charAt ( i ) == "-" ) mi = true ; continue ; } mi = false ; if ( sh == 0 ) this [ this . t ++ ] = x ; else if ( sh + k > this . DB ) { this [ this . t - 1 ] |= ( x & ( ( 1 << ( this . DB - sh ) ) - 1 ) ) << sh ; this [ this . t ++ ] = ( x >> ( this . DB - sh ) ) ; } else this [ this . t - 1 ] |= x << sh ; sh += k ; if ( sh >= this . DB ) sh -= this . DB ; } if ( k == 8 && ( s [ 0 ] & 0x80 ) != 0 ) { this . s = - 1 ; if ( sh > 0 ) this [ this . t - 1 ] |= ( ( 1 << ( this . DB - sh ) ) - 1 ) << sh ; } this . clamp ( ) ; if ( mi ) Int128 . ZERO . subTo ( this , this ) ; }
(protected) set from string and radix
( protected ) set from string and radix
// byte array