Java Integer Clip clip(int a, int min, int max)

Here you can find the source of clip(int a, int min, int max)

Description

clip

License

Open Source License

Declaration

public static final int clip(int a, int min, int max) 

Method Source Code

//package com.java2s;
/*//from ww  w .jav  a2  s . c o  m
 * Copyright (c) 2006-2011 Karsten Schmidt
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * http://creativecommons.org/licenses/LGPL/2.1/
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */

public class Main {
    public static final double clip(double a, double min, double max) {
        return a < min ? min : (a > max ? max : a);
    }

    public static final float clip(float a, float min, float max) {
        return a < min ? min : (a > max ? max : a);
    }

    public static final int clip(int a, int min, int max) {
        return a < min ? min : (a > max ? max : a);
    }
}

Related

  1. clip(final int value)
  2. clip(int lower, int upper, int x)
  3. clip(int val, int from, int to)
  4. clip(int val, int from, int to)
  5. clip(int x)