Here you can find the source of randomRange(double min, double max)
Parameter | Description |
---|---|
min | The minimum inclusive value |
max | The maximum inclusive value |
public static double randomRange(double min, double max)
//package com.java2s; /**// w w w.ja v a 2 s . co m * CamanJ - Java Image Manipulation * Ported from the CamanJS Javascript library * * Copyright 2011, Ryan LeFevre * Licensed under the new BSD License * See LICENSE for more info. * * Project Home: http://github.com/meltingice/CamanJ */ public class Main { /** * Returns a pseudorandom double within the given range. * * @param min * The minimum inclusive value * @param max * The maximum inclusive value * @return The pseudorandom value */ public static double randomRange(double min, double max) { return min + (Math.random() * ((max - min) + 1)); } /** * Returns a pseudorandom int within the given range. * * @param min * The minimum inclusive value * @param max * The maximum inclusive value * @return The pseudorandom value */ public static int randomRange(int min, int max) { return min + (int) (Math.random() * ((max - min) + 1)); } }