Java Random Int randIntv(double fr, double to)

Here you can find the source of randIntv(double fr, double to)

Description

rand Intv

License

Open Source License

Declaration

public static double randIntv(double fr, double to) 

Method Source Code

//package com.java2s;
/**//from w w  w . j  a  v  a2 s.com
 * Copyright (c) Lambda Innovation, 2013-2015
 * ?????????Lambda Innovation???
 * http://www.li-dev.cn/
 *
 * This project is open-source, and it is distributed under 
 * the terms of GNU General Public License. You can modify
 * and distribute freely as long as you follow the license.
 * ?????????????????GNU?????????????
 * ????????????????????????????
 * http://www.gnu.org/licenses/gpl.html
 */

import java.util.Random;

public class Main {
    private static Random RNG = new Random();

    public static int randIntv(int fr, int to) {
        return RNG.nextInt(to - fr) + fr;
    }

    public static double randIntv(double fr, double to) {
        return (to - fr) * RNG.nextDouble() + fr;
    }
}

Related

  1. randInt(int range)
  2. randInt(int range)
  3. RandInt(int x, int y)
  4. randIntArray(int length)
  5. randIntArray(int length)
  6. randLocation(int min, int max)
  7. Random(int a, boolean Zero)
  8. random(int length)
  9. random(int length)