 # Can I shift a BigInt

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.

``````1L << (1L << 5) - 1// equals 4294967295
1L << (1L << 6) - 1 // equal -9223372036854775808 unfortunately
``````

So I tried the following, but it won’t compile.

``````i < (BigInt(1) << (1L << j))
i < (BigInt(1) << (BigInt(1) << j))
i < (BigInt(1) << (BigInt(1) << BigInt(j)))
``````

With the following error or similar

``````Error:(159, 64) type mismatch;
found   : scala.math.BigInt
required: Int
require(BigInt(i) < (BigInt(1)<<(BigInt(1)<<BigInt(j))) )
``````

Does this mean that `<<` does not support `BigInt` ? Is that intended or an oversight?

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.
``````BigInt(i) < (BigInt(1) << (1 << numVars))