Class MathUtils

java.lang.Object
growthbook.sdk.java.util.MathUtils

public class MathUtils extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static float
    clamp(float value, float lowerRange, float upperRange)
    Given a value, ensures it's clamped between the range provided
    static long
    fnv1a_32(byte[] data)
    Fowler-Noll-Vo algorithm fnv32a returns a long, so we convert that to a float using a modulus
    static float
    sum(List<Float> items)
    Add up all the numbers

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MathUtils

      public MathUtils()
  • Method Details

    • fnv1a_32

      public static long fnv1a_32(byte[] data)
      Fowler-Noll-Vo algorithm fnv32a returns a long, so we convert that to a float using a modulus
      Parameters:
      data - byte list
      Returns:
      long
    • clamp

      public static float clamp(float value, float lowerRange, float upperRange)
      Given a value, ensures it's clamped between the range provided
      Parameters:
      value - The number you want to make sure is between lowerRange and upperRange
      lowerRange - The lowest value
      upperRange - The highest value
      Returns:
      the clamped number
    • sum

      public static float sum(List<Float> items)
      Add up all the numbers
      Parameters:
      items - Numbers to add
      Returns:
      total