static calculateBCHCode(value /*int*/, poly /*int*/) {
        if (poly === 0) {
            throw new IllegalArgumentException('0 polynomial');
        }
        // If poly is "1 1111 0010 0101" (version info poly), msbSetInPoly is 13. We'll subtract 1
        // from 13 to make it 12.
        const msbSetInPoly = MatrixUtil.findMSBSet(poly);
        value <<= msbSetInPoly - 1;
        // Do the division business using exclusive-or operations.
        while (MatrixUtil.findMSBSet(value) >= msbSetInPoly) {
            value ^= poly << (MatrixUtil.findMSBSet(value) - msbSetInPoly);
        }
        // Now the "value" is the remainder (i.e. the BCH code)
        return value;
    }
// operations. We don't care if coefficients are positive or negative.
operations. We don't care if coefficients are positive or negative.
operations . We don ' t care if coefficients are positive or negative .
static calculateBCHCode(value , poly ) {
        if (poly === 0) {
            throw new IllegalArgumentException('0 polynomial');
        }
        const msbSetInPoly = MatrixUtil.findMSBSet(poly);
        value <<= msbSetInPoly - 1;
        while (MatrixUtil.findMSBSet(value) >= msbSetInPoly) {
            value ^= poly << (MatrixUtil.findMSBSet(value) - msbSetInPoly);
        }
        return value;
    }
static calculateBCHCode ( value , poly ) { if ( poly === 0 ) { throw new IllegalArgumentException ( '0 polynomial' ) ; } const msbSetInPoly = MatrixUtil . findMSBSet ( poly ) ; value <<= msbSetInPoly - 1 ; while ( MatrixUtil . findMSBSet ( value ) >= msbSetInPoly ) { value ^= poly << ( MatrixUtil . findMSBSet ( value ) - msbSetInPoly ) ; } return value ; }
operations.
operations .
/*int*/ /*int*/ // If poly is "1 1111 0010 0101" (version info poly), msbSetInPoly is 13. We'll subtract 1 // from 13 to make it 12. // Do the division business using exclusive-or operations. // Now the "value" is the remainder (i.e. the BCH code)