aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2011-12-28 21:16:59 +0000
committerlloyd <[email protected]>2011-12-28 21:16:59 +0000
commit0327d46856edbac4bc8bcaf5a3d793142bbd880d (patch)
treeaeecb520995464cb6e0962d716f856651d74b058
parentf29ca5483570aa0974b484e5cfebaecf62124133 (diff)
Rounding to nearest 0 should be a no-op
-rw-r--r--src/utils/rounding.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/utils/rounding.h b/src/utils/rounding.h
index c77ab9b52..78b9eeb5d 100644
--- a/src/utils/rounding.h
+++ b/src/utils/rounding.h
@@ -21,6 +21,9 @@ namespace Botan {
template<typename T>
inline T round_up(T n, T align_to)
{
+ if(align_to == 0)
+ return n;
+
if(n % align_to || n == 0)
n += align_to - (n % align_to);
return n;
@@ -35,6 +38,9 @@ inline T round_up(T n, T align_to)
template<typename T>
inline T round_down(T n, T align_to)
{
+ if(align_to == 0)
+ return n;
+
return (n - (n % align_to));
}