code: public Integer nextValue()
      {
          // Regenerate the fixed point representation of p if it has changed.
          double newP = p.nextValue();
          if (pBits == null || newP != lastP)
          {
              lastP = newP;
              pBits = BinaryUtils.convertDoubleToFixedPointBits(newP);
          }
  
          int trials = n.nextValue();
          int totalSuccesses = 0;
          int pIndex = pBits.getLength() - 1;
  
          while (trials > 0 && pIndex >= 0)
          {
              int successes = binomialWithEvenProbability(trials);
              trials -= successes;
              if (pBits.getBit(pIndex))
              {
                  totalSuccesses += successes;
              }
              --pIndex;
          }
  
          return totalSuccesses;
      }
docs: Generate the next binomial value from the current values of
  {@literal n} and {@literal p}.  The algorithm used is from
  The Art of Computer Programming Volume 2 (Seminumerical Algorithms)
  by Donald Knuth (page 589 in the Third Edition) where it is
  credited to J.H. Ahrens.