Here you can find the source of clamp(double weight, double lowerBound, double upperBound)
public static double clamp(double weight, double lowerBound, double upperBound)
//package com.java2s; //License from project: Apache License public class Main { public static double clamp(double weight, double lowerBound, double upperBound) { if (weight > upperBound) { weight = upperBound;//w w w. j av a2 s. c o m } else if (weight < lowerBound) { weight = lowerBound; } return weight; } }