Java Double Number Clamp clamp(double min, double max, double val)

Here you can find the source of clamp(double min, double max, double val)

Description

clamp

License

Open Source License

Declaration

public static double clamp(double min, double max, double val) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static double clamp(double min, double max, double val) {
        if (val > max)
            return max;
        else if (val < min)
            return min;
        else/*w w w  .java 2s.  c  o  m*/
            return val;
    }

    public static long clamp(long min, long max, long val) {
        if (val > max)
            return max;
        else if (val < min)
            return min;
        else
            return val;
    }

    public static float clamp(float min, float max, float val) {
        if (val > max)
            return max;
        else if (val < min)
            return min;
        else
            return val;
    }

    public static int clamp(int min, int max, int val) {
        if (val > max)
            return max;
        else if (val < min)
            return min;
        else
            return val;
    }
}

Related

  1. clamp(double d, double min, double max)
  2. clamp(double d, double min, double max)
  3. clamp(double f)
  4. clamp(double f, double f1, double f2)
  5. clamp(double min, double arg, double max)
  6. clamp(double min, double max, double value)
  7. clamp(double min, double value, double max)
  8. clamp(double number)
  9. clamp(double v, double l, double h)