If you possibly raise 2 to some power, you can use the bitwise left shift operator:
let x = 2 << 0 // 2 let y = 2 << 1 // 4 let z = 2 << 7 // 256
Note that the value of "power" is 1 less than you think.
Note that this is faster than pow(2.0, 8.0) and avoids the use of doubles.
chanceoperation Feb 22 '15 at 23:16 2015-02-22 23:16
source share