Java examples for java.lang:Math Value
Wraps the given value into the inclusive-exclusive interval between min and max.
//package com.java2s; public class Main { /**/* ww w. jav a 2 s . c o m*/ * Wraps the given value into the inclusive-exclusive interval between min and max. * @param n The value to wrap. * @param min The minimum. * @param max The maximum. */ static double wrap(double n, double min, double max) { return (n >= min && n < max) ? n : (mod(n - min, max - min) + min); } /** * Returns the non-negative remainder of x / m. * @param x The operand. * @param m The modulus. */ static double mod(double x, double m) { return ((x % m) + m) % m; } }