<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">// Class MyMath
// - contains irritating random() code

public class MyMath {
    // lowest error term for random double:
       private static final double error = Double.MIN_VALUE;   
    // base value ("error") for random int
       private static final int    base  = 1;                  

    // Return a random integer in range [low,high]:
       public static int random(int low, int high) {
	   return (int) (Math.random()*(high-low+base)+low); 
       }
    
    // Return a random double in range [low,high]:
       public static double random(double low, double high) {
	   double r=Math.random()*(high-low+error)+low;
	   
	   // Ensure that r &lt;= h:
	   if (r&gt;high) r=high;
	   
	   return r;
       }
    
} // class MyMath
</pre></body></html>