Powers of 2 POW

Really stuck folks.

Just had a problem with a part of code which assigns security permissions. I have used a binary security check and so am using powers of 2 to assign permissions. Everything was going wrong so I wrote this bit of code to try and get to the bottom of it.
echo “

I=”.$i." Power=".pow(2,$i)."

So…very simple, just output the powers of 2 starting at 0 and going up to 50.
Here is the output:
I=0 Power=1
I=1 Power=2
I=2 Power=4…
etc, no problem there then.
But further down…
I=47 Power=140737488355330
I=48 Power=281474976710660
I=49 Power=562949953421310

Now, here is the problem. According to my spreadsheet,
2 to the power 47 is actually 140737488355328.
2 to the power 48 is actually 281474976710656
2 to the power 49 is actually 562949953421312

What is going on!

Sponsor our Newsletter | Privacy Policy | Terms of Service