Java Float Number Clamp clamp(float f)

Here you can find the source of clamp(float f)

Description

Clamp the given value to [0, 1]

License

Open Source License

Declaration

private static float clamp(float f) 

Method Source Code

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

public class Main {
    /**/*from   w ww  .  j a  v  a  2s  . c  om*/
     * Clamp the given value to [0, 1]
     */
    private static float clamp(float f) {
        f = f < 0.0f ? 0.0f : f;
        f = f > 1.0f ? 1.0f : f;
        return f;
    }
}

Related

  1. clamp(final float val, final float min, final float max)
  2. clamp(final float value, final float min, final float max)
  3. clamp(final float x, final float a, final float b)
  4. clamp(float a, float min, float max)
  5. Clamp(float a, float min, float max)
  6. clamp(float f, float min, float max)
  7. clamp(float f, float min, float max)
  8. clamp(float input, float min, float max)
  9. clamp(float min, float max, float val)