Java Random randRangeDecimal(float min, float max)

Here you can find the source of randRangeDecimal(float min, float max)

Description

Calculates a random number within a minimum and maximum range.

License

Open Source License

Parameter

Parameter Description
min the value for the bottom range.
max the value for the upper range.

Return

the random number within the range.

Declaration

public static float randRangeDecimal(float min, float max) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**//from   ww w. j  a  v  a  2 s .  c o m
     *  Calculates a random number within a minimum and maximum range.
     *  @param  min   the value for the bottom range.
     *  @param  max   the value for the upper range.
     *  @return the random number within the range.
     *  @use    {@code var vRandRange = MathUtil.randRangeDecimal( 0, 999999 );}
     */
    public static float randRangeDecimal(float min, float max) {
        return (float) Math.random() * (max - min) + min;
    }
}

Related

  1. randomValue()
  2. randomValue(T[] array)
  3. randomVector(int size)
  4. randRandom(Random random)
  5. randRange(float from, float to)
  6. resetRandomGenerator()
  7. runProbability(Random rng, float[] probs, D[] choices)