public static double trimToRange(double untrimmedValue,double min,double max){
  return Math.max(min,Math.min(max,untrimmedValue));
}

public static double trimToRange ( double untrimmedValue , double min , double max ) { return Math . max ( min , Math . min ( max , untrimmedValue ) ) ; }
trim the given value so that it is in the closed interval [ min , max ] .
