Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
1 files changed, 3 insertions, 3 deletions
-rw-r--r--src/LEDVideoWall.cpp6
diff --git a/src/LEDVideoWall.cpp b/src/LEDVideoWall.cpp
index 5fb69ac..abdbcf0 100644
--- a/src/LEDVideoWall.cpp
+++ b/src/LEDVideoWall.cpp
@@ -18,9 +18,9 @@ LEDVideoWall* LEDVideoWall::Freeform(mm panel_width, mm panel_height, mm wall_ma
// GCD is available in stl from C++17 onwards, but I'm still reimplementing it
unsigned int gcd(unsigned int a, unsigned int b) {
- if (a == b) return a;
- if (a < b) return gcd(b, a);
- return gcd(a - b, b);
+ // Eucledian algorithm https://en.wikipedia.org/wiki/Greatest_common_divisor#Euclidean_algorithm
+ if (b == 0) return a;
+ return gcd(b, a % b);
}
LEDVideoWall* LEDVideoWall::Aspect(mm panel_width, mm panel_height, unsigned int aspect_width, unsigned int aspect_height) {