Java Random Float Number randomFloat(float min, float max)

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

Description

random Float

License

Open Source License

Declaration

public static float randomFloat(float min, float max) 

Method Source Code

//package com.java2s;
/**/*from  w w w  .  j a v a  2 s  . c o  m*/
 * Project:   warnme-server
 * File:      RandomUtils.java
 * License: 
 *            This file is licensed under GNU General Public License version 3
 *            http://www.gnu.org/licenses/gpl-3.0.txt
 *
 * Copyright: Bartosz Cichecki [ cichecki.bartosz@gmail.com ]
 * Date:      Apr 24, 2014
 */

import java.text.DecimalFormat;

public class Main {
    public static float randomFloat(float min, float max) {
        Float f = (float) (min + Math.random() * (max - min + 1));
        return Float.valueOf(new DecimalFormat("#.##").format(f));
    }
}

Related

  1. randFloat(float min, float max)
  2. randFloat(float min, float max)
  3. randFloat(float min, float max, long seed)