1,使用<<計算2的N次方 1 2 var value = 1<<4 //2的4次方 var value = 1<< Int (arc4random_uniform(5)) //2的0~4随機次方(包括0,4)