Java Double Number Clamp clampFloat(double in)

Here you can find the source of clampFloat(double in)

Description

Clamps a number to the range supported by float data type.

License

Open Source License

Declaration

public static final float clampFloat(double in) 

Method Source Code

//package com.java2s;
/*//from ww w .  j  av a  2  s .c  o m
 * $RCSfile: ImageUtil.java,v $
 *
 * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
 *
 * Use is subject to license terms.
 *
 * $Revision: 1.2 $
 * $Date: 2006/07/21 20:53:28 $
 * $State: Exp $
 */

public class Main {
    /** The minimum value of a float. */
    private static final float FLOAT_MIN = -Float.MAX_VALUE;

    /** Clamps a number to the range supported by float data type. */
    public static final float clampFloat(double in) {
        return (in > Float.MAX_VALUE ? Float.MAX_VALUE : (in >= FLOAT_MIN ? (float) in : FLOAT_MIN));
    }
}

Related

  1. clamp_double(double p_151237_0_, double p_151237_2_, double p_151237_4_)
  2. clamp_doubleback(double a, double x, double y)
  3. clamp_latitude(double lat)
  4. clampAngle(double angle)
  5. clampedLerp(double lowerBnd, double upperBnd, double slide)
  6. clampMax(double val, double max)
  7. clampMax(final double MAX, final double VALUE)
  8. clampMin(double input, double min)
  9. clampRoundShort(double in)