Java Double Number Clamp clamp(double number)

Here you can find the source of clamp(double number)

Description

clamp

License

Open Source License

Declaration

public static double clamp(double number) 

Method Source Code

//package com.java2s;
/*/*from  w  w w. j ava  2  s.  c  o m*/
 * Texture Generator Library by Andy Gibson
 *
 * This software is distributed under the terms of the FSF Lesser
 * Gnu Public License. It is provided as-is, without any express
 * or implied warranty, or guarantee of any kind.
 *
 */

public class Main {
    public static int clamp(int number) {
        if (number > 255) {
            number = 255;
        }

        if (number < 0) {
            number = 0;
        }
        return number;
    }

    public static double clamp(double number) {
        if (number > 1) {
            number = 1;
        }

        if (number < 0) {
            number = 0;
        }
        return number;
    }
}

Related

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