Here you can find the source of clamp01(long value)
Clamp the given value between 0 and 1 .
Parameter | Description |
---|---|
value | The value to clamp. |
public static long clamp01(long value)
//package com.java2s; // The MIT License(MIT) public class Main { /**//from ww w. j a v a 2 s .c om * <p> * Clamp the given {@code value} between {@code 0} and {@code 1}. * </p> * * @param value The value to clamp. * @return The clamped value. */ public static long clamp01(long value) { return clamp(value, 0, 1); } /** * <p> * Clamp the given {@code value} between {@code 0} and {@code 1}. * </p> * * @param value The value to clamp. * @return The clamped value. */ public static double clamp01(double value) { return clamp(value, 0, 1); } /** * <p> * Clamp the given {@code value} between {@code 0} and {@code 1}. * </p> * * @param value The value to clamp. * @return The clamped value. */ public static float clamp01(float value) { return clamp(value, 0, 1); } /** * <p> * Clamp the given {@code value} between {@code 0} and {@code 1}. * </p> * * @param value The value to clamp. * @return The clamped value. */ public static int clamp01(int value) { return clamp(value, 0, 1); } /** * <p> * Clamp the given {@code value} between a {@code min} and a {@code max} value. * </p> * * @param value The value to clamp. * @param min The minimum value. * @param max The maximum value. * @return The clamped value. */ public static long clamp(long value, long min, long max) { return Math.max(min, Math.min(max, value)); } /** * <p> * Clamp the given {@code value} between a {@code min} and a {@code max} value. * </p> * * @param value The value to clamp. * @param min The minimum value. * @param max The maximum value. * @return The clamped value. */ public static double clamp(double value, double min, double max) { return Math.max(min, Math.min(max, value)); } /** * <p> * Clamp the given {@code value} between a {@code min} and a {@code max} value. * </p> * * @param value The value to clamp. * @param min The minimum value. * @param max The maximum value. * @return The clamped value. */ public static float clamp(float value, float min, float max) { return Math.max(min, Math.min(max, value)); } /** * <p> * Clamp the given {@code value} between a {@code min} and a {@code max} value. * </p> * * @param value The value to clamp. * @param min The minimum value. * @param max The maximum value. * @return The clamped value. */ public static int clamp(int value, int min, int max) { return Math.max(min, Math.min(max, value)); } }