Java Double Number Align align(double min, double number, double max)

Here you can find the source of align(double min, double number, double max)

Description

aligns number between min and max (guarantees number stays within inclusive bounds of min and max)

License

LGPL

Parameter

Parameter Description
min a parameter
number a parameter
max a parameter

Declaration

public static double align(double min, double number, double max) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

public class Main {
    /**//from ww  w.  jav  a2s.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));
    }
}

Related

  1. align(double min, double number, double max)