code: public static int asInt(final double datum, final int n) {
      final double d = (datum == 0.0) ? 0.0 : datum; //canonicalize -0.0, 0.0
      final long[] data = { Double.doubleToLongBits(d) };//canonicalize all NaN forms
      return asInteger(data, n); //data is long[]
    }
docs: Returns a deterministic uniform random integer between zero (inclusive) and
  n (exclusive) given the input double.
  @param datum the given double.
  @param n The upper exclusive bound of the integers produced. Must be &gt; 1.
  @return deterministic uniform random integer