Java Integer Clamp clamp_wrap(int a, int x, int y)

Here you can find the source of clamp_wrap(int a, int x, int y)

Description

Returns the given double clamped between the two values (wraps around if out of range).

License

Open Source License

Declaration

public static int clamp_wrap(int a, int x, int y) 

Method Source Code

//package com.java2s;

public class Main {
    /**//from  w  w  w  .  j a va2s  .  co m
     * Returns the given double clamped between the two values (wraps around if out of range).
     */
    public static int clamp_wrap(int a, int x, int y) {
        return a < x ? y - (x - a) % (y - x) : a > y ? x + (a - y) % (y - x) : a;
    }

    /**
     * Returns the given double clamped between the two values (wraps around if out of range).
     */
    public static double clamp_wrap(double a, double x, double y) {
        return a < x ? y - Math.IEEEremainder(x - a, y - x) : a > y ? x + Math.IEEEremainder(a - y, y - x) : a;
    }
}

Related

  1. clamp(int var, int min, int max)
  2. clamp(int x, int min, int max)
  3. clamp(int x, int min, int max)
  4. clamp(String string, int maxChars)
  5. clamp_int(int num, int min, int max)
  6. clampAngle(int angle)
  7. clampByte(int in)
  8. clampColor(int c)
  9. clampColorInt(int color)