Here you can find the source of align(int min, int number, int max)
public static int align(int min, int number, int max)
//package com.java2s; //License from project: LGPL public class Main { /**/*from w w w. j a va 2 s . c o m*/ * aligns number between min and max (guarantees number stays within * inclusive bounds of min and max) * * @param min * @param number * @param max * @return */ public static double align(double min, double number, double max) { return Math.min(max, Math.max(min, number)); } public static int align(int min, int number, int max) { return Math.min(max, Math.max(min, number)); } }