diff --git a/prism/src/prism/PrismUtils.java b/prism/src/prism/PrismUtils.java index 1afde7cd..28f5e751 100644 --- a/prism/src/prism/PrismUtils.java +++ b/prism/src/prism/PrismUtils.java @@ -70,6 +70,14 @@ public class PrismUtils return Math.log(x) / Math.log(2); } + /** + * Compute the number of bits needed to encode n different values. + */ + public static int bitsForEncoding(int n) + { + return (int) Math.ceil(PrismUtils.log2(n)); + } + /** * See if two doubles are within epsilon of each other (absolute error). */