decode(received, twoS /*int*/) {
			const field = this.field;
			const poly = new GenericGFPoly(field, received);
			const syndromeCoefficients = new Int32Array(twoS);
			let noError = true;
			for (let i = 0; i < twoS; i++) {
				const evalResult = poly.evaluateAt(field.exp(i + field.getGeneratorBase()));
				syndromeCoefficients[syndromeCoefficients.length - 1 - i] = evalResult;
				if (evalResult !== 0) {
					noError = false;
				}
			}
			if (noError) {
				return;
			}
			const syndrome = new GenericGFPoly(field, syndromeCoefficients);
			const sigmaOmega = this.runEuclideanAlgorithm(field.buildMonomial(twoS, 1), syndrome, twoS);
			const sigma = sigmaOmega[0];
			const omega = sigmaOmega[1];
			const errorLocations = this.findErrorLocations(sigma);
			const errorMagnitudes = this.findErrorMagnitudes(omega, errorLocations);
			for (let i = 0; i < errorLocations.length; i++) {
				const position = received.length - 1 - field.log(errorLocations[i]);
				if (position < 0) {
					throw new ReedSolomonException('Bad error location');
				}
				received[position] = GenericGF.addOrSubtract(received[position], errorMagnitudes[i]);
			}
		}
<p>Decodes given set of received codewords, which include both data and error-correction
codewords. Really, this means it uses Reed-Solomon to detect and correct errors, in-place,
in the input.</p>

@param received data and error-correction codewords
@param twoS number of error-correction codewords available
@throws ReedSolomonException if decoding fails for any reason