Android Float Clamp clampByte(float value)

Here you can find the source of clampByte(float value)

Description

clamp Byte

License

Open Source License

Declaration

private static byte clampByte(float value) 

Method Source Code

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

public class Main {
    private static byte clampByte(float value) {
        return (byte) clamp(Byte.MIN_VALUE, Byte.MAX_VALUE, value);
    }/*from  w  w  w  .  j  a v  a2s .  co  m*/

    private static float clamp(float min, float max, float value) {
        final float clamp;
        if (value < min) {
            clamp = min;
        } else if (value > max) {
            clamp = max;
        } else {
            clamp = value;
        }
        return clamp;
    }
}

Related

  1. clamp(float x, float min, float max)
  2. clamp(float min, float max, float value)