Here you can find the source of between(float value, float min, float max)
public static boolean between(float value, float min, float max)
//package com.java2s; /** Copyright 2014 Robin Stumm (serverkorken@gmail.com, http://dermetfan.net) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ public class Main { /** @return if the given value is in between min and max (exclusive) * @see #between(float, float, float, boolean) */ public static boolean between(float value, float min, float max) { return between(value, min, max, false); }/*from w ww. jav a 2s . co m*/ /** min and max will be swapped if they are given in the wrong order * @param inclusive if the given value is allowed to be equal to min or max * @return if the given value is in between min and max */ public static boolean between(float value, float min, float max, boolean inclusive) { min = Math.min(min, max); max = Math.max(min, max); return inclusive ? value >= min && value <= max : value > min && value < max; } /** @return the smallest element of the given array */ public static float min(float[] floats) { float min = Float.POSITIVE_INFINITY; for (float f : floats) if (f < min) min = f; return min; } /** @return the largest element of the given array */ public static float max(float[] floats) { float max = Float.NEGATIVE_INFINITY; for (float f : floats) if (f > max) max = f; return max; } }