Java Float Number Clamp clamp(float x, float y, float z)

Here you can find the source of clamp(float x, float y, float z)

Description

Returns middle value from all three

License

Open Source License

Parameter

Parameter Description
x Number one
y Number two
z Number three

Return

The middle number

Declaration

public static float clamp(float x, float y, float z) 

Method Source Code

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

public class Main {
    /**/*  w ww  .  j ava  2s.co m*/
     * Returns middle value from all three
     * @param x Number one
     * @param y Number two
     * @param z Number three
     * @return The middle number
     */
    public static float clamp(float x, float y, float z) {
        if (x > y) {
            float tmp = x;

            x = y;
            y = tmp;
        }

        return Math.max(x, Math.min(y, z));
    }
}

Related

  1. clamp(float value, float min, float max)
  2. clamp(float value, float min, float max)
  3. clamp(float value, float minimum, float maximum)
  4. clamp(float value, float minimum, float maximum)
  5. clamp(float x, float a, float b)
  6. clamp180(float r1, float r2)
  7. clamp1f(float f)
  8. clamp360(float dir)
  9. clamp_float(float p_76131_0_, float p_76131_1_, float p_76131_2_)