Class MathUtils


  • public final class MathUtils
    extends java.lang.Object
    Basic math-related functions that are not included in Math or Google Guava.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static float EPSILON  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static float average​(java.util.Collection<? extends java.lang.Number> numbers)  
      static int ceiling​(float n)  
      static float clamp​(float value, float min, float max)  
      static int clamp​(int value, int min, int max)  
      static long clamp​(long value, long min, long max)  
      static boolean isPowerOfTwo​(int n)  
      static int nextPowerOfTwo​(int n)  
      static int signum​(float n)  
      static int signum​(int n)  
      static int sum​(int[] values)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • ceiling

        public static int ceiling​(float n)
      • signum

        public static int signum​(int n)
      • signum

        public static int signum​(float n)
      • sum

        public static int sum​(int[] values)
      • clamp

        public static int clamp​(int value,
                                int min,
                                int max)
      • clamp

        public static float clamp​(float value,
                                  float min,
                                  float max)
      • clamp

        public static long clamp​(long value,
                                 long min,
                                 long max)
      • average

        public static float average​(java.util.Collection<? extends java.lang.Number> numbers)
      • isPowerOfTwo

        public static boolean isPowerOfTwo​(int n)
      • nextPowerOfTwo

        public static int nextPowerOfTwo​(int n)