core/src/main/java/org/bouncycastle/pqc/crypto/qtesla/Sample.java
/*****************************************************************************************************************
     * Description:	Samples A Bit from Bernoulli with Restriction of 20-Bit Exponent
     *****************************************************************************************************************/
Samples A Bit from Bernoulli with Restriction of 20-Bit Exponent
Samples A Bit from Bernoulli with Restriction of 20 - Bit Exponent
private static int bernoulli(long result, long fractionOfExponent, double[][] exponentialDistribution)
    {
        /* *
         * Computes the Actual Bernoulli Parameter = exp (-t / f)
         * Yields A Fraction of 2^62, to Keep Only 62 Bits of Precision in This Implementation
         * */
        double bernoulliParameter = 4611686018427387904.0;
        for (long i = 0, j = fractionOfExponent; i < 3; i++, j >>= 5)
        {
            bernoulliParameter *= exponentialDistribution[(int)i][(int)(j & 31)];
        }
        /* Sample from Bernoulli of bernoulliParameter */
        return (int)(((result & 0x3FFFFFFFFFFFFFFFL) - Math.round(bernoulliParameter)) >>> 63);
    }
private static int bernoulli ( long result , long fractionOfExponent , double [ ] [ ] exponentialDistribution ) { /* *
         * Computes the Actual Bernoulli Parameter = exp (-t / f)
         * Yields A Fraction of 2^62, to Keep Only 62 Bits of Precision in This Implementation
         * */ double bernoulliParameter = 4611686018427387904.0 ; for ( long i = 0 , j = fractionOfExponent ; i < 3 ; i ++ , j >>= 5 ) { bernoulliParameter *= exponentialDistribution [ ( int ) i ] [ ( int ) ( j & 31 ) ] ; } /* Sample from Bernoulli of bernoulliParameter */ return ( int ) ( ( ( result & 0x3FFFFFFFFFFFFFFFL ) - Math . round ( bernoulliParameter ) ) >>> 63 ) ; }
Description:     Samples A Bit from Bernoulli with Restriction of 20-Bit Exponent
Description : Samples A Bit from Bernoulli with Restriction of 20 - Bit Exponent