function bnpFromString()

in public/amazon-cognito-identity.js [3526:3550]


function bnpFromString(s, b) {
	var k;
	if (b == 16) k = 4;else if (b == 8) k = 3;else if (b == 2) k = 1;else if (b == 32) k = 5;else if (b == 4) k = 2;else throw new Error('Only radix 2, 4, 8, 16, 32 are supported');
	this.t = 0;
	this.s = 0;
	var i = s.length,
	    mi = false,
	    sh = 0;
	while (--i >= 0) {
		var x = 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;
	}
	this.clamp();
	if (mi) BigInteger.ZERO.subTo(this, this);
}