Java Integer Clip clip(final int value)

Here you can find the source of clip(final int value)

Description

Clip a value for compare

License

Open Source License

Parameter

Parameter Description
value the value to clip

Return

the value in the range [-1, 1]

Declaration

public static final int clip(final int value) 

Method Source Code

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

public class Main {
    /**/*from w  w  w  . jav  a 2s .co  m*/
     * Clip a value for compare
     *
     * @param value the value to clip
     * @return the value in the range [-1, 1]
     */
    public static final int clip(final int value) {
        if (value <= -1) {
            return -1;
        }
        if (value >= 1) {
            return 1;
        }
        return 0;
    }
}

Related

  1. clip(int a, int min, int max)
  2. clip(int lower, int upper, int x)
  3. clip(int val, int from, int to)
  4. clip(int val, int from, int to)