public static float checkArgumentInRange ( float value , float lower , float upper , String valueName ) { if ( Float . isNaN ( value ) ) { throw new IllegalArgumentException ( valueName + " must not be NaN" ) ; } else if ( value < lower ) { throw new IllegalArgumentException ( String . format ( Locale . US , "%s is out of range of [%f, %f] (too low)" , valueName , lower , upper ) ) ; } else if ( value > upper ) { throw new IllegalArgumentException ( String . format ( Locale . US , "%s is out of range of [%f, %f] (too high)" , valueName , lower , upper ) ) ; } return value ; }
Ensures that the argument floating point value is within the inclusive range .