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

Clamps d between min and max.

License

Open Source License

Parameter

Parameter Description
d The value to clamp.
min The minimum.
max The maximum.

Return

The clamped value.

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 {
    /**//from w  ww  .  ja v  a 2  s  . co  m
     * Clamps d between min and max.
     * 
     * @param d The value to clamp.
     * @param min The minimum.
     * @param max The maximum.
     * @return The clamped value.
     */
    public static double clamp(double d, double min, double max) {
        if (d < min)
            return min;
        else if (d > max)
            return max;
        else
            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)
  6. clamp(double f, double f1, double f2)
  7. clamp(double min, double arg, double max)