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

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

Description

clamp

License

Open Source License

Declaration

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

Method Source Code

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

public class Main {
    public static double clamp(double d, double min, double max) {
        if (d < min)
            d = min;/*from w w w .j a va 2  s  . c o  m*/
        if (d > max)
            d = max;
        return d;
    }

    public static double[] clamp(double[] d, double min, double max) {
        for (int i = 0; i < d.length; i++)
            d[i] = clamp(d[i], min, max);
        return d;
    }
}

Related

  1. clamp(double a, double min, double max)
  2. clamp(double d, double min, double max)
  3. clamp(double d, double min, double max)
  4. clamp(double d, double min, double max)
  5. clamp(double f)