diff --git a/prism/src/prism/PrismUtils.java b/prism/src/prism/PrismUtils.java index 94309532..48fde428 100644 --- a/prism/src/prism/PrismUtils.java +++ b/prism/src/prism/PrismUtils.java @@ -67,6 +67,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). */