From 66a4b69a29bebfb056fef243281d7c8356445c04 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Sun, 19 Feb 2023 00:48:56 +0200 Subject: [PATCH] BAN: Math now uses template concepts and add div_round_up --- BAN/include/BAN/Math.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/BAN/include/BAN/Math.h b/BAN/include/BAN/Math.h index b98356f3a..30931ff35 100644 --- a/BAN/include/BAN/Math.h +++ b/BAN/include/BAN/Math.h @@ -1,5 +1,7 @@ #pragma once +#include + namespace BAN::Math { @@ -21,7 +23,7 @@ namespace BAN::Math return x < min ? min : x > max ? max : x; } - template + template T gcd(T a, T b) { T t; @@ -34,10 +36,16 @@ namespace BAN::Math return a; } - template + template T lcm(T a, T b) { return a / gcd(a, b) * b; } + template + T div_round_up(T a, T b) + { + return (a + b - 1) / b; + } + } \ No newline at end of file