I’d like to know whether some integer i <= 2^2^j - 1
The way I’m tempted do this is i < (1L<<(1L<<j)) - 1
However the << sometimes produces the wrong result.

Here is what I’m really trying to do. I want to avoid genKthBdd being called where truthTable is more than a 2^numVars bit binary number.

// if the 1 bits of the binary representation of truthTable denote the T
// rows in the truth table, with the least significant bit representing
// variable x1. (there is no x0)
// truthTable is interpreted as a 2^n-bit binary number. 0 <= truthTable < 2^(2^n)
def genKthBdd(numVars: Int, truthTable: Long): Bdd = {
require(truthTable >= 0 , s"truthTable=$truthTable")
require(numVars > 0)
require(truthTable < (1L<<(1L<<numVars))) // this is WRONG!
// we interpret truthTable as a 'function' mapping the range 0<=i<2^n to Boolean
// whose value is true if there is a 1 in the ith position of truthTable,
// considering the 0'th position as the least significant bit.
genBddFromBitMask(numVars, maxNumBits=numVars, maxNumTerms=1<<numVars, isRowSet(truthTable, _))
}