Package ej.bon

Class XMath


  • public final class XMath
    extends Object
    This class provides advanced mathematical functions.
    • Constructor Summary

      Constructors 
      Constructor Description
      XMath()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static double limit​(double value, double min, double max)
      Limits a value between two others: If value is lower than min, returns min. If value is greater than max, returns max. Otherwise, returns value.
      static float limit​(float value, float min, float max)
      Limits a value between two others: If value is lower than min, returns min. If value is greater than max, returns max. Otherwise, returns value.
      static int limit​(int value, int min, int max)
      Limits a value between two others: If value is lower than min, returns min. If value is greater than max, returns max. Otherwise, returns value.
      static long limit​(long value, long min, long max)
      Limits a value between two others: If value is lower than min, returns min. If value is greater than max, returns max. Otherwise, returns value.
    • Constructor Detail

      • XMath

        public XMath()
    • Method Detail

      • limit

        public static int limit​(int value,
                                int min,
                                int max)
        Limits a value between two others:
        1. If value is lower than min, returns min.
        2. If value is greater than max, returns max.
        3. Otherwise, returns value.
        Parameters:
        value - the value to limit
        min - the lower bound
        max - the upper bound
        Returns:
        the limited value
        Throws:
        IllegalArgumentException - if min is greater than max
      • limit

        public static float limit​(float value,
                                  float min,
                                  float max)
        Limits a value between two others:
        1. If value is lower than min, returns min.
        2. If value is greater than max, returns max.
        3. Otherwise, returns value.
        Parameters:
        value - the value to limit
        min - the lower bound
        max - the upper bound
        Returns:
        the limited value
        Throws:
        IllegalArgumentException - if min is greater than max
      • limit

        public static long limit​(long value,
                                 long min,
                                 long max)
        Limits a value between two others:
        1. If value is lower than min, returns min.
        2. If value is greater than max, returns max.
        3. Otherwise, returns value.
        Parameters:
        value - the value to limit
        min - the lower bound
        max - the upper bound
        Returns:
        the limited value
        Throws:
        IllegalArgumentException - if min is greater than max
      • limit

        public static double limit​(double value,
                                   double min,
                                   double max)
        Limits a value between two others:
        1. If value is lower than min, returns min.
        2. If value is greater than max, returns max.
        3. Otherwise, returns value.
        Parameters:
        value - the value to limit
        min - the lower bound
        max - the upper bound
        Returns:
        the limited value
        Throws:
        IllegalArgumentException - if min is greater than max