Java Unsigned Number Create unsignedConstraintValue(double v, double min, double max)

Here you can find the source of unsignedConstraintValue(double v, double min, double max)

Description

Constraint the given value to the upper and lower bound

License

Open Source License

Parameter

Parameter Description
v the value to constraint
min the lower bound (only values >= 0 are applied)
max the upper bound (only values >= 0 are applied)

Return

the value

Declaration

public static double unsignedConstraintValue(double v, double min, double max) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2016 BestSolution.at and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors://from ww  w  .  ja va 2  s . co  m
 *     Tom Schindl<tom.schindl@bestsolution.at> - initial API and implementation
 *******************************************************************************/

public class Main {
    /**
     * Constraint the given value to the upper and lower bound
     *
     * @param v
     *            the value to constraint
     * @param min
     *            the lower bound (only values >= 0 are applied)
     * @param max
     *            the upper bound (only values >= 0 are applied)
     * @return the value
     * @since 2.2.0
     */
    public static double unsignedConstraintValue(double v, double min, double max) {
        double rv = v;
        if (min >= 0) {
            rv = Math.max(rv, min);
        }

        if (max >= 0) {
            rv = Math.min(rv, max);
        }
        return rv;
    }
}

Related

  1. unsignedByteValue(final byte input)
  2. unsignedChar(char c)
  3. unsignedChar(int val)
  4. unsignedCharToInt(byte[] b)
  5. unsignedCompare(long left, long right)
  6. unsignedDiv(long l1, long l2)
  7. unsignedExtend(String hex)
  8. unsignedHalfwordToString(int value)
  9. unsignedInt(byte b)