summaryrefslogtreecommitdiff
path: root/src/main/java/org/mamago/util/Bits.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/mamago/util/Bits.java')
-rw-r--r--src/main/java/org/mamago/util/Bits.java16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/main/java/org/mamago/util/Bits.java b/src/main/java/org/mamago/util/Bits.java
new file mode 100644
index 0000000..4672ea9
--- /dev/null
+++ b/src/main/java/org/mamago/util/Bits.java
@@ -0,0 +1,16 @@
+package org.mamago.util;
+
+public class Bits {
+ // Prevent instantiation
+ private Bits() {}
+
+ public static int roundUpToLongSize(int size) {
+ return roundUpToSize(size, 8);
+ }
+
+ public static int roundUpToSize(int size, int width) {
+ // Formula:
+ // (size + w) / w * w; // Adding w rounds up to the next whole width
+ return ((size + width) / width) * width;
+ }
+}