package bigfft

import (
	
)

// FromDecimalString converts the base 10 string
// representation of a natural (non-negative) number
// into a *big.Int.
// Its asymptotic complexity is less than quadratic.
func ( string) *big.Int {
	var  scanner
	 := new(big.Int)
	.scan(, )
	return 
}

type scanner struct {
	// powers[i] is 10^(2^i * quadraticScanThreshold).
	powers []*big.Int
}

func ( *scanner) ( int) (int, *big.Int) {
	if  <= quadraticScanThreshold {
		panic("size < quadraticScanThreshold")
	}
	 := uint(0)
	for  := ;  > quadraticScanThreshold;  /= 2 {
		++
	}
	// threshold * 2^(pow-1) <= size < threshold * 2^pow
	return quadraticScanThreshold << ( - 1), .power( - 1)
}

func ( *scanner) ( uint) *big.Int {
	for  := len(.powers);  <= int(); ++ {
		 := new(big.Int)
		if  == 0 {
			if quadraticScanThreshold%14 != 0 {
				panic("quadraticScanThreshold % 14 != 0")
			}
			.Exp(big.NewInt(1e14), big.NewInt(quadraticScanThreshold/14), nil)
		} else {
			.Mul(.powers[-1], .powers[-1])
		}
		.powers = append(.powers, )
	}
	return .powers[]
}

func ( *scanner) ( *big.Int,  string) {
	if len() <= quadraticScanThreshold {
		.SetString(, 10)
		return
	}
	,  := .chunkSize(len())
	// Scan the left half.
	.(, [:len()-])
	// FIXME: reuse temporaries.
	 := Mul(, )
	// Scan the right half
	.(, [len()-:])
	.Add(, )
}

// quadraticScanThreshold is the number of digits
// below which big.Int.SetString is more efficient
// than subquadratic algorithms.
// 1232 digits fit in 4096 bits.
const quadraticScanThreshold = 1232