1
0

rename Unsigned.size to Unsigned.clog2

This commit is contained in:
Andrew Waterman 2014-06-06 16:59:55 -07:00
parent 3828c628c3
commit 7bffc6c586

View File

@ -6,10 +6,10 @@ import scala.math._
class Unsigned(x: Int) {
require(x >= 0)
def size: Int = { require(x > 0); ceil(log(x)/log(2)).toInt }
def clog2: Int = { require(x > 0); ceil(log(x)/log(2)).toInt }
def log2: Int = { require(x > 0); floor(log(x)/log(2)).toInt }
def isPow2: Boolean = x > 0 && (x & (x-1)) == 0
def nextPow2: Int = if (x == 0) 1 else 1 << size
def nextPow2: Int = if (x == 0) 1 else 1 << clog2
}
object Util {