Package growthbook.sdk.java.util
Class MathUtils
java.lang.Object
growthbook.sdk.java.util.MathUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic doubleclamp(double value, double lowerRange, double upperRange) Given a value, ensures it's clamped between the range providedstatic longfnv1a_32(byte[] data) Fowler-Noll-Vo algorithm fnv32a returns a long, so we convert that to a double using a modulusstatic longFowler-Noll-Vo FNV-1a 32 over the string's UTF-16 code units, like the JS SDK, which XORs eachcharCodeAtvalue.static doubleAdd up all the numbers
-
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 double using a modulus- Parameters:
data- byte list- Returns:
- long
-
fnv1a_32
Fowler-Noll-Vo FNV-1a 32 over the string's UTF-16 code units, like the JS SDK, which XORs eachcharCodeAtvalue. A character outside the BMP contributes its two surrogates.- Parameters:
value- the string to hash- Returns:
- the unsigned 32-bit hash
-
clamp
public static double clamp(double value, double lowerRange, double 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 upperRangelowerRange- The lowest valueupperRange- The highest value- Returns:
- the clamped number
-
sum
Add up all the numbers- Parameters:
items- Numbers to add- Returns:
- total
-