Probabilities { public static int toInt(final float probability) { return Math.round(INT_RANGE*probability + Integer.MIN_VALUE); } private  Probabilities(); static int toInt(final float probability); static int toInt(final double probability); static float toFloat(final int probability);  }
@Test public void probabilityToInt() { Assert.assertEquals(Probabilities.toInt(0), Integer.MIN_VALUE); Assert.assertEquals(Probabilities.toInt(1), Integer.MAX_VALUE); Assert.assertEquals(Probabilities.toInt(0.5), 0); Assert.assertEquals(Probabilities.toInt(0.25), Integer.MIN_VALUE/2); Assert.assertEquals(Probabilities.toInt(0.75), Integer.MAX_VALUE/2); }