mathutil.java

来自「Struts2 + Spring JPA Hibernate demo.」· Java 代码 · 共 43 行

JAVA
43
字号
/*
 * $Id: MathUtil.java 9 2006-03-08 10:21:59Z wjx $
 */
package com.vegeta.utils;

/**
 * Misc math utils.
 *
 * <p><a href="MathUtil.java.html"><i>View Source</i></a></p>
 *
 * @version $Revision: 9 $ $Date: 2006-03-08 18:21:59 +0800 (星期三, 08 三月 2006) $
 */
public final class MathUtil {

	/**
	 * Generates pseudo-random long from specific range. Generated number is
	 * great or equals to min parameter value and less then max parameter value.
	 *
	 * @param min    lower (inclusive) boundary
	 * @param max    higher (exclusive) boundary
	 *
	 * @return pseudo-random value
	 */

	public static long randomLong(long min, long max) {
		return min + (long)(Math.random() * (max - min));
	}


	/**
	 * Generates pseudo-random integer from specific range. Generated number is
	 * great or equals to min parameter value and less then max parameter value.
	 *
	 * @param min    lower (inclusive) boundary
	 * @param max    higher (exclusive) boundary
	 *
	 * @return pseudo-random value
	 */
	public static int randomInt(int min, int max) {
		return min + (int)(Math.random() * (max - min));
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?