From 040246cb3a8be23d77dcbc86fc72b0965ad82a86 Mon Sep 17 00:00:00 2001 From: Vincenzo Sicurella Date: Sun, 14 Jul 2024 02:08:51 -0400 Subject: [PATCH] fix factorization bug --- Source/lumatone_editor_library/common/math.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Source/lumatone_editor_library/common/math.h b/Source/lumatone_editor_library/common/math.h index d4f4238..346592f 100644 --- a/Source/lumatone_editor_library/common/math.h +++ b/Source/lumatone_editor_library/common/math.h @@ -15,7 +15,9 @@ const double PI = 3.14159265359f; -static int PRIMES[100] = { +#define LTN_MAX_PRIMES 100 + +static int PRIMES[LTN_MAX_PRIMES] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, @@ -105,7 +107,7 @@ static juce::Array getFactors(int numIn) double factorized = numIn; - int maxPrime = (int)sqrt(numIn); + int maxPrime = PRIMES[LTN_MAX_PRIMES - 1]; while (factorized > 1.0) {